Skip to content

fix(search): a search before the graph is open finds nothing, no error - #13857

Closed
yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/search-before-index-open
Closed

yuxi-liu-wired wants to merge 1 commit into
logseq:masterfrom
yuxi-liu-wired:fix/search-before-index-open

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

A search before the graph is open finds nothing, without an error

A search sent while the graph is still opening (typing in the search dialog right after a reload) reaches frontend.worker.search/search-blocks before the worker has the graph's datascript conn or its search db:

  • nil conn: DB worker API failed: :thread-api/search-blocks Error: No protocol method IDeref.-deref defined for type null (thrown from search-blocks);
  • nil search db: TypeError: Cannot read properties of null (reading 'exec'), logged by search-blocks-aux's catch.

Found by a local key fuzzer that reloads mid-session and opens the search dialog.

Change

search-blocks returns nothing until both the conn and the search db exist (src/main/frontend/worker/search.cljs).

Test

src/test/frontend/worker/search_test.cljs search-blocks-before-the-graph-is-open: searches with no search db (all blocks and pages only) and with no conn, and asserts an empty result and no console.error. On master the nil conn throws and the nil search db logs the TypeError twice.

CI's unit suite and lint pass locally.


Devin Review

A search sent while the graph is still opening (the search dialog right
after a reload) reached frontend.worker.search/search-blocks with a nil
datascript conn or a nil search db. A nil conn threw "No protocol method
IDeref.-deref defined for type null" (shown as "DB worker API failed:
:thread-api/search-blocks"); a nil search db made the sqlite query log
"TypeError: Cannot read properties of null (reading 'exec')". A local
key fuzzer that reloads mid-session hit both.

search-blocks returns nothing until both exist.

search-blocks-before-the-graph-is-open searches with no search db and
with no conn, and asserts an empty result and no logged error; without
the change the nil conn throws and the nil search db logs the TypeError.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

q (or (tag-title-query q) q)]
(when-not (string/blank? q)
;; no graph conn or search db yet (the graph is still opening, e.g. right after a reload): nothing to search
(when (and conn search-db (not (string/blank? q)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Graph readiness does not refresh search

After an early search-blocks call returns nil, the dialog can retain empty results when the graph opens. Its refresh key excludes worker readiness; unchanged input triggers no new search.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

The dialog showing nothing for a search sent before the graph opened isn't new: on master the same early search fails (No protocol method IDeref.-deref defined for type null, or the logged exec TypeError) and the dialog shows no results either. This change only removes the error. Re-running the search when the graph becomes ready would be a dialog change (its refresh key), separate from this fix.

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Superseded by #13864, which fixes the cause instead of each handler: calls for a graph that is still opening now wait for the open in remote-function, so they see the opened graph. This PR's commits are included there as the backstop for calls that arrive when no open is in flight. Closing to keep the fix for this class in one place.

@yuxi-liu-wired
yuxi-liu-wired deleted the fix/search-before-index-open branch November 17, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant