Skip to content

Commit 900a0d6

Browse files
committed
enhance(rtc): add logs for rtc-start
1 parent 4679528 commit 900a0d6

File tree

2 files changed

+55
-45
lines changed

2 files changed

+55
-45
lines changed

src/main/frontend/handler/db_based/rtc.cljs

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -105,37 +105,42 @@
105105

106106
(defn <rtc-start!
107107
[repo & {:keys [stop-before-start?] :or {stop-before-start? true}}]
108-
(when-let [graph-uuid (ldb/get-graph-rtc-uuid (db/get-db repo))]
109-
(p/do!
110-
(js/Promise. user-handler/task--ensure-id&access-token)
111-
(p/let [start-ex (state/<invoke-db-worker :thread-api/rtc-start stop-before-start?)
112-
ex-data* (ex-data start-ex)
113-
_ (case (:type ex-data*)
114-
(:rtc.exception/not-rtc-graph
115-
:rtc.exception/not-found-db-conn)
116-
(notification/show! (ex-message start-ex) :error)
108+
(let [db (db/get-db repo)
109+
graph-uuid (ldb/get-graph-rtc-uuid db)]
110+
(if-not graph-uuid
111+
(log/error :<rtc-start! ["graph-uuid not found" repo])
112+
(p/do!
113+
(js/Promise. user-handler/task--ensure-id&access-token)
114+
(p/let [start-ex (state/<invoke-db-worker :thread-api/rtc-start stop-before-start?)
115+
ex-data* (ex-data start-ex)
116+
_ (case (:type ex-data*)
117+
(:rtc.exception/not-rtc-graph
118+
:rtc.exception/not-found-db-conn)
119+
(notification/show! (ex-message start-ex) :error)
117120

118-
:rtc.exception/major-schema-version-mismatched
119-
(case (:sub-type ex-data*)
120-
:download
121-
(notification-download-higher-schema-graph! repo graph-uuid (:remote ex-data*))
122-
:create-branch
123-
(notification-upload-higher-schema-graph! repo)
124-
;; else
125-
(do (log/info :start-ex start-ex)
126-
(notification/show! [:div
127-
[:div (ex-message start-ex)]
128-
[:div (-> ex-data*
129-
(select-keys [:app :local :remote])
130-
pp/pprint
131-
with-out-str)]]
132-
:error)))
121+
:rtc.exception/major-schema-version-mismatched
122+
(case (:sub-type ex-data*)
123+
:download
124+
(notification-download-higher-schema-graph! repo graph-uuid (:remote ex-data*))
125+
:create-branch
126+
(notification-upload-higher-schema-graph! repo)
127+
;; else
128+
(do (log/info :start-ex start-ex)
129+
(notification/show! [:div
130+
[:div (ex-message start-ex)]
131+
[:div (-> ex-data*
132+
(select-keys [:app :local :remote])
133+
pp/pprint
134+
with-out-str)]]
135+
:error)))
133136

134-
:rtc.exception/lock-failed nil
137+
:rtc.exception/lock-failed nil
135138

136-
;; else
137-
nil)]
138-
nil))))
139+
;; else
140+
nil)]
141+
nil)))
142+
143+
))
139144

140145
(defn <get-remote-graphs
141146
[]

src/main/frontend/worker/rtc/core.cljs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -378,23 +378,28 @@
378378
(let [repo (worker-state/get-current-repo)
379379
token (worker-state/get-id-token)
380380
conn (worker-state/get-datascript-conn repo)]
381-
(when (and repo
382-
(sqlite-util/db-based-graph? repo)
383-
token conn)
384-
(when stop-before-start? (rtc-stop))
385-
(let [ex (m/? (new-task--rtc-start* repo token))]
386-
(when-let [ex-data* (ex-data ex)]
387-
(case (:type ex-data*)
388-
(:rtc.exception/not-rtc-graph
389-
:rtc.exception/major-schema-version-mismatched
390-
:rtc.exception/lock-failed)
391-
(log/info :rtc-start-failed ex)
392-
393-
:rtc.exception/not-found-db-conn
394-
(log/error :rtc-start-failed ex)
395-
396-
(log/error :BUG-unknown-error ex))
397-
ex))))))
381+
(if-not (and repo
382+
(sqlite-util/db-based-graph? repo)
383+
conn token)
384+
(log/error :new-task--rtc-start-failed
385+
{:repo repo
386+
:some?-conn (some? conn)
387+
:some?-token (some? token)})
388+
(do
389+
(when stop-before-start? (rtc-stop))
390+
(let [ex (m/? (new-task--rtc-start* repo token))]
391+
(when-let [ex-data* (ex-data ex)]
392+
(case (:type ex-data*)
393+
(:rtc.exception/not-rtc-graph
394+
:rtc.exception/major-schema-version-mismatched
395+
:rtc.exception/lock-failed)
396+
(log/info :rtc-start-failed ex)
397+
398+
:rtc.exception/not-found-db-conn
399+
(log/error :rtc-start-failed ex)
400+
401+
(log/error :BUG-unknown-error ex))
402+
ex)))))))
398403

399404
(defn rtc-stop
400405
[]

0 commit comments

Comments
 (0)