Repository navigation
Bug: session search crashes with RangeError: Invalid string length on large sessions (root cause + fix)
#1859
Replies: 7 comments
Update (2026-08-16): the incremental fingerprint alone was not enough — full root cause + a complete local fixThe incremental-hash change stopped the What was actually wrong (beyond the 512 MB string cap)Every search still re-observed the entire corpus, so memory cost stayed proportional to the workspace, not the query:
The other half of the bug: Chinese queries matched nothingTwo independent causes: (a) the whole query was quoted as one FTS5 phrase, so multi-term queries required exact adjacency; (b) FTS5 The fix (complete in our working tree, tested, not yet a PR)
Verification
@zoahdev — both of your points land: the clone-and-hash-per-event cost is now gone at the source (no clones anywhere in the observation path), and the preemptive size signal is still valuable — note the v9 index reset means the first search after upgrading is heavier than usual, which is a natural trigger for that check. One known remaining gap: the exact-read paths ( The changes sit in our working tree of |
Update 2 (2026-08-16): the first fix shipped, and
|
|
大会话搜索 RangeError(Invalid string length)——SQLite 查询把大字符串拼到内存爆了,和 #1473/#1497 的大会话家族相关但性质不同(是查询层不是持久化层)。 带根因+修复很好,会话管理第 8 章有相关:https://github.com/Electricitysheep/dsh-handbook/blob/main/docs/08-tools-context.md |
Update 3 (2026-08-16): every search failed after the round-two fix — root cause: the stability gate starved against the write-behind flushAfter round two shipped, searches stopped erroring out with OOM and started erroring out with
Fix
Verification against the real corpusWith a live owner for the actively flushing session: first search 13 s (the one-time v9 rebuild, 16 inspections), then 38 ms and 17 ms with zero re-inspections — the incremental index is warm again. All 271 session-query tests green; typecheck, lint, and coverage gates clean. Artifacts patched into the running install; restarting |
Patch location — complete fix lives in my fork (official PRs not yet accepted)The official repo is not accepting PRs yet, so the complete round-one + round-two + stability fix is committed and pushed to my fork:
The branch is based on official |
|
Follow-up from running this in production (DeepSeek Harness Plus): we reproduced the
Verified in the live deployment: no crash, CJK phrases match with readable snippets, the GUI stays responsive while a giant session indexes (max main-thread stall ~2.3s vs ~5s before the worker offload), and a search whose reconciliation exceeds the budget returns partial results + a hint rather than timing out. Happy to upstream any of these pieces; the fingerprint + CJK parts are the smallest independent contribution. |
Uh oh!
There was an error while loading. Please reload this page.
session-query SQLite: workspace search crashes on large sessions (
RangeError: Invalid string length)Summary
session_search/session_event_searchreturnError: session query operation failedonce any session in a workspace grows large enough. The underlying error is aRangeError: Invalid string lengththrown during search-index reconciliation, and it takes down search for the entire workspace, not just the big session. Session listing and exact event reads keep working, which hides the failure for a while.Root cause
observeSession()inpackages/session-query/session-query-sqlite/src/index.tscomputes the change fingerprint by serializing the whole event log into one string:V8 caps a single string at ~512 MB (2^29-1 characters). With a session holding millions of events (observed live with ~5M events; a persisted log of ~150 MB raw / 223k events is already enough), the stringify output crosses the cap and
JSON.stringifythrows:The reconciliation failure aborts the query, so every search in that workspace fails. The tool layer additionally masks the real error behind the generic
session query operation failedmessage (SESSION_QUERY_INVALID_CONFIG/SESSION_QUERY_SOURCE_CONFLICTmapping intool-session-query/service-boundary.ts).Reproduction
session_searchin that workspace.Error: session query operation failedfor any query, while session listing and exact reads still work.Proposed fix
Hash the fingerprint incrementally — header once, then each event separately — so memory stays bounded:
Side effect: fingerprints change once for every session (one-time index rebuild), which is expected whenever the hash construction changes.
Verification
dsh-session-query-sqlite/lib/index.jsand restarteddsh web: bothsession_searchandsession_event_searchwork again in that workspace, including over the large session.Observed on
@deepseek-ai/dsh-session-query-sqlite0.1.0-rc.6 (published dsh family); the same pattern is present atmasterin this repository.All reactions