fix: keep graphs list usable when db-worker is nil - #13064
Draft
tiensonqin wants to merge 3 commits into
Draft
Conversation
After a failed graph open or worker recovery, *db-worker can be nil. <invoke-db-worker threw synchronously, so All graphs and restore/sync-context hit React ErrorBoundary instead of a recoverable empty/error state. Reject the missing-worker case as a promise, skip worker-backed list-db, and avoid throwing that error from renderer subscriptions. Co-authored-by: Tienson Qin <[email protected]>
Read event-definitions as an atom, and set *db-worker in undo/redo proxy tests so the ready? guard does not skip the redef. Co-authored-by: Tienson Qin <[email protected]>
Call done after promesa with-redefs restores bindings so restore tests cannot overlap. Assert db-worker-ready? before checking that sync-context invokes the worker. Co-authored-by: Tienson Qin <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes logseq/db-test#1077
After a failed graph open or worker recovery,
*db-workercan be nil.<invoke-db-workerused to throwdb-worker has not been initializedsynchronously. Promesap/letdoes not catch that first-binding throw, so React render, RFX, restore, and All graphs hit ErrorBoundary (“Something is wrong”) instead of a recoverable empty/error state.Change
<invoke-db-workeralways returns a promise and rejects when the worker is missing, instead of throwing.<list-db>returns[]when the worker is not ready (no SQLite error toast / reload loop).:graph/sync-contextno-ops unless the worker is ready.:graph/loading?and keeps the current graph so the graphs list remains usable.Not in scope: db-test#1076 (import NPE), #1066/#1074 (sleep/wake reconnect), #927 (import recovery).
Tests
frontend.state-test/invoke-db-worker-with-nil-worker-rejects-without-throwingfrontend.persist-db-test/browser-list-db-with-nil-worker-returns-empty-without-throwingfrontend.db.restore-test/restore-graph-with-nil-worker-rejects-without-throwingfrontend.db.hooks-testuninitialized worker error does not throw fromuse-blockfrontend.handler.events-test:graph/sync-contextnil-worker / readyfrontend.undo-redo-test/undo-redo-with-nil-worker-does-not-throw-testfrontend.components.repo-test/graph-e2ee-enabled-with-nil-worker-does-not-throw