Bug: session search crashes with RangeError: Invalid string length on large sessions (root cause + fix)
#1859
Replies: 2 comments
|
Endorsing the incremental-fingerprint fix ? the V8 cap mechanism checks out, and the error-masking in Two additions to the fix:
The reproduced 223k-event threshold (~150 MB raw) is a great regression fixture ? worth adding to |
|
The preemptive signal is now shipped: dsh-plugin-doctor v1.10.0 adds a npx dsh-plugin-doctor --profile ~/.dsh/profiles/web --json
# ? large-files: warn | sessions/huge.jsonl (150.0 MB) ?25/25 tests (3 new fixtures: under threshold PASS / over threshold WARN with path / dependency-tree skip). Release: https://github.com/zoahdev/dsh-plugin-doctor/releases/tag/v1.10.0 ? the upstream incremental-hash fix remains the real cure; this catches the cliff early. |
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