Repository navigation
fix(views): a references view isn't created for a node that is gone - #13852
Closed
yuxi-liu-wired wants to merge 1 commit into
Closed
yuxi-liu-wired wants to merge 1 commit into
yuxi-liu-wired wants to merge 1 commit into
Conversation
A page's linked/unlinked references section creates its view block the
first time it renders (create-view!, :outliner-op :create-view). When the
page was removed while its section was still mounted (an undo chain
removing a page just created, e.g. by a paste), the section created a view
whose :logseq.property/view-for is the gone page. The worker refused the
write ("DB write failed with invalid data", view-for "should be a node
with a title"). A local key fuzzer hit it four times in one run of 24.
create-view! now reads the view's parent by uuid first and creates no
view when it is gone. Views for a parent that exists are created as
before.
create-view-skips-a-parent-that-is-gone-test runs create-view! for a
parent the db no longer returns (no insert; before the change it inserted
the view) and for one that exists (one insert).
Contributor
Author
|
Superseded by #13782, which closes this in the db worker instead of the client: a client check reads the client's own copy of the db, so a write can still reach the worker after its target is gone. #13782 drops such writes in the worker (property writes from the app's |
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.
Problem
A page's linked/unlinked references section creates its view block the first time it renders (
create-view!insrc/main/frontend/components/views.cljs, outliner op:create-view). When the page is removed while its section is still mounted, e.g. an undo chain that removes a page just made by a paste, the section creates a view whose:logseq.property/view-foris the gone page, and the worker refuses the write:DB worker API failed: :thread-api/apply-outliner-ops Error: DB write failed with invalid data, with the view entity's:logseq.property/view-for"should be a node with a title". A local key fuzzer (random editor keys, Ctrl+K navigation and undo/redo chains, sent with no wait) hit it four times in one run of 24.Cause
create-view!builds the view fromview-parent, the entity the component last rendered, and never checks that it still exists before sendingapi-insert-new-block!.Fix
create-view!reads the parent by its uuid first (db-async/<get-block) and creates no view when it is gone. A parent that exists gets its view as before.Tests
frontend.components.views-test/create-view-skips-a-parent-that-is-gone-test:create-view!for a parent the db no longer returns sends no insert (before the change it inserted the view), for a parent that exists one insert. Fails without the change, passes with it.frontend.components.views-testpasses; CI's whole unit suite (pnpm cljs:run-test) passes apart fromfrontend.db.query-dsl-test/block-property-query-performance, a 40 ms timing check that took 43 ms on a loaded machine and passes on its own; lint (kondo, large vars, typos) is clean.