diff --git a/src/electron/electron/handler.cljs b/src/electron/electron/handler.cljs index bf643fd54..027458e90 100644 --- a/src/electron/electron/handler.cljs +++ b/src/electron/electron/handler.cljs @@ -304,6 +304,15 @@ (async/put! state/persistent-dbs-chan true) true) +;; The renderer sends this when frontend.db/persist! rejected. Without a method here +;; it fell through to :default, electron.window/close-handler stayed parked on +;; persistent-dbs-chan forever, and the window could never be closed again. Unblock the +;; close: the markdown files are the source of truth, the transit file is only a cache. +(defmethod handle :persistent-dbs-error [_window _] + (logger/error "Failed to persist the graph cache. Closing anyway - your files on disk are unaffected, but the next startup will re-index.") + (async/put! state/persistent-dbs-chan true) + true) + ;; Search related IPCs (defmethod handle :search-blocks [_window [_ repo q opts]] (search/search-blocks repo q opts)) @@ -691,8 +700,11 @@ (defmethod handle :cancel-all-requests [_ args] (apply rsapi/cancel-all-requests (rest args))) -(defmethod handle :default [args] - (logger/error "Error: no ipc handler for:" args)) +;; `handle` is dispatched with two arguments, so a one-argument :default threw an arity +;; exception instead of logging -- and the exception was swallowed by set-ipc-handler!, +;; hiding the unhandled channel entirely. Log the channel name rather than the window. +(defmethod handle :default [_window args] + (logger/error "Error: no ipc handler for:" (first args))) (defn broadcast-persist-graph! "Receive graph-name (not graph path) diff --git a/src/electron/electron/window.cljs b/src/electron/electron/window.cljs index 6523d4ebc..880107326 100644 --- a/src/electron/electron/window.cljs +++ b/src/electron/electron/window.cljs @@ -14,6 +14,12 @@ (defonce *quitting? (atom false)) +(def ^:private persist-dbs-timeout-ms + "How long close-handler waits for the renderer to confirm the graph cache was saved + before closing the window regardless. Generous enough for a large graph to serialize, + short enough that a user never faces a window that simply refuses to close." + 10000) + (def MAIN_WINDOW_ENTRY (if dev? ;"http://localhost:3001" (str "file://" (node-path/join js/__dirname "index.html")) @@ -89,12 +95,17 @@ (.send web-contents "persist-zoom-level" (.getZoomLevel web-contents)) (.send web-contents "persistent-dbs")) (async/go - (let [_ (async/