From cc48b42d05366c980f43c64fd665f9513bae8d25 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Mon, 1 Dec 2025 21:05:12 +0800 Subject: [PATCH] enhance: handler other situations when rtc doesn't auto-start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Worker RTC fail handling now treats websocket closes (ws-timeout, ws-already-disconnected, and raw CloseEvent) as restart-worthy, automatically re-requesting a start. - RTC stop now clears any stored last-stop exception and emits a final state with rtc-lock false instead of immediately zeroing metadata, so the UI sees the stopped state and auto-start triggers can fire; metadata is still emptied only when we truly have no repo. - If a start attempt is skipped because the DB connection isn’t ready (but we already have a token), a short retry is scheduled to avoid needingmanual “Start sync.” --- src/main/frontend/worker/rtc/core.cljs | 38 +++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/main/frontend/worker/rtc/core.cljs b/src/main/frontend/worker/rtc/core.cljs index 2ef07cee21..4718dac6cd 100644 --- a/src/main/frontend/worker/rtc/core.cljs +++ b/src/main/frontend/worker/rtc/core.cljs @@ -375,9 +375,11 @@ (log/info :rtc-loop-task e) (when-not (or (instance? Cancelled e) (= "missionary.Cancelled" (ex-message e))) (println (.-stack e))) - (when (= :rtc.exception/ws-timeout (some-> e ex-data :type)) - ;; if fail reason is websocket-timeout, try to restart rtc - (worker-state/ e ex-data :type)] + (when (or (= :rtc.exception/ws-timeout t) + (instance? js/CloseEvent e)) + ;; if fail reason is websocket/connection related, try to restart rtc + (worker-state/