Repository navigation
fix(search): a search before the graph is open finds nothing, no error - #13857
yuxi-liu-wired wants to merge 1 commit into
Conversation
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.
| 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))) |
There was a problem hiding this comment.
🔍 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
The dialog showing nothing for a search sent before the graph opened isn't new: on master the same early search fails ( |
|
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 |
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-blocksbefore the worker has the graph's datascript conn or its search db:DB worker API failed: :thread-api/search-blocks Error: No protocol method IDeref.-deref defined for type null(thrown fromsearch-blocks);TypeError: Cannot read properties of null (reading 'exec'), logged bysearch-blocks-aux's catch.Found by a local key fuzzer that reloads mid-session and opens the search dialog.
Change
search-blocksreturns nothing until both the conn and the search db exist (src/main/frontend/worker/search.cljs).Test
src/test/frontend/worker/search_test.cljssearch-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 noconsole.error. On master the nil conn throws and the nil search db logs the TypeError twice.CI's unit suite and lint pass locally.