mirror of
https://github.com/logseq/logseq.git
synced 2026-05-21 03:12:38 +00:00
enhance(rtc): try to restart rtc if stop reason is ws-timeout
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
(ns frontend.handler.db-based.rtc-flows
|
||||
"Flows related to RTC"
|
||||
(:require [frontend.common.missionary :as c.m]
|
||||
[frontend.common.thread-api :as thread-api :refer [def-thread-api]]
|
||||
[frontend.flows :as flows]
|
||||
[frontend.mobile.flows :as mobile-flows]
|
||||
[frontend.state :as state]
|
||||
@@ -94,6 +95,10 @@ conditions:
|
||||
(assert (some? repo))
|
||||
(reset! *rtc-start-trigger repo))
|
||||
|
||||
(def-thread-api :thread-api/rtc-start-request
|
||||
[repo]
|
||||
(trigger-rtc-start repo))
|
||||
|
||||
(def ^:private document-visible&rtc-not-running-flow
|
||||
(m/ap
|
||||
(let [visibility (m/?< flows/document-visibility-state-flow)]
|
||||
|
||||
@@ -10,4 +10,4 @@
|
||||
|
||||
(if config/dev?
|
||||
(log/set-levels {:glogi/root :info})
|
||||
(log/set-levels {:glogi/root :warn}))
|
||||
(log/set-levels {:glogi/root :info}))
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
[frontend.worker.thread-atom]
|
||||
[frontend.worker.util :as worker-util]
|
||||
[goog.object :as gobj]
|
||||
[lambdaisland.glogi :as log]
|
||||
[lambdaisland.glogi.console :as glogi-console]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.db :as ldb]
|
||||
@@ -841,6 +842,7 @@
|
||||
(into {})
|
||||
bean/->js)]
|
||||
(glogi-console/install!)
|
||||
(log/set-levels {:glogi/root :info})
|
||||
(check-worker-scope!)
|
||||
(outliner-register-op-handlers!)
|
||||
(<ratelimit-file-writes!)
|
||||
|
||||
@@ -247,6 +247,7 @@
|
||||
started-dfv
|
||||
(m/sp
|
||||
(try
|
||||
(log/info :rtc :loop-starting)
|
||||
;; init run to open a ws
|
||||
(m/? get-ws-create-task)
|
||||
(started-dfv true)
|
||||
@@ -368,7 +369,10 @@
|
||||
rtc-loop-task
|
||||
:fail (fn [e]
|
||||
(reset! *last-stop-exception e)
|
||||
(log/info :rtc-loop-task e)))
|
||||
(log/info :rtc-loop-task e)
|
||||
(when (= :rtc.exception/ws-timeout (some-> e ex-data :type))
|
||||
;; if fail reason is websocket-timeout, try to restart rtc
|
||||
(worker-state/<invoke-main-thread :thread-api/rtc-start-request repo))))
|
||||
start-ex (m/? onstarted-task)]
|
||||
(if (instance? ExceptionInfo start-ex)
|
||||
(do
|
||||
|
||||
Reference in New Issue
Block a user