fix: db-worker stops working after hot-reload

This commit is contained in:
Tienson Qin
2026-03-17 18:59:52 +08:00
parent fb76b061b4
commit 55834b541d
3 changed files with 10 additions and 7 deletions

View File

@@ -91,7 +91,6 @@
(defn ^:export stop []
;; stop is called before any code is reloaded
;; this is controlled by :before-load in the config
(handler/stop!)
(js/console.log "stop"))
(defn ^:export delay-remount

View File

@@ -181,11 +181,6 @@
(reset! vector-search-flows/*infer-worker-ready true))))
nil)))))))
(defn stop! []
(db-browser/stop-workers!)
(reset! vector-search-flows/*infer-worker-ready false)
(prn "stop!"))
(defn quit-and-install-new-version!
[]
(p/let [_ (ipc/invoke "set-quit-dirty-state" false)]

View File

@@ -57,7 +57,15 @@
[missionary.core :as m]
[promesa.core :as p]))
(.importScripts js/self "worker.js")
(def ^:private worker-bootstrap-loaded-key "__logseq_db_worker_bootstrap_loaded__")
(defn- ensure-worker-bootstrap!
[]
(when-not (gobj/get js/self worker-bootstrap-loaded-key)
(gobj/set js/self worker-bootstrap-loaded-key true)
(.importScripts js/self "worker.js")))
(ensure-worker-bootstrap!)
(declare <build-blocks-fts!)
@@ -1171,6 +1179,7 @@
(defn- notify-invalid-data
[{:keys [tx-meta]} errors]
;; don't notify on production when undo/redo failed
(when-not (and (or (:undo? tx-meta) (:redo? tx-meta))
(not worker-util/dev?))
(shared-service/broadcast-to-clients! :notification