You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(usage): stop retaining full session-file text forever, root cause of the crash
Root cause of the "closes for no reason, kills every session" crash, found while the
crash was reproducing live: usageScan's per-file cache stored the FULL TEXT of every
Claude session .jsonl file forever (keyed by path, replaced on mtime change, but never
evicted otherwise, and never bounded by size). projectsView.ts calls usage:report(0)
(all-time, unconditionally) on every deck load to fill in each card's cost badge — so
on a cold start this cache gets populated with EVERY BYTE of the user's entire history.
Measured on the real data: ~/.claude/projects held 5,070 session files totaling 2.5GB
on disk (one single transcript was 347MB). Live process inspection during an actual
crash cycle showed the main process ballooning to ~3.8GB within ~2 minutes of a cold
start — a V8 "JavaScript heap out of memory" abort at that size bypasses uncaughtException/
unhandledRejection entirely (nothing was ever logged to devdeck-errors.log despite v1.12.1's
new traps) and takes every cockpit terminal down with the main process.
Fix: files over MAX_CACHED_FILE_BYTES (5MB) are still read and aggregated correctly, but
never RETAINED in the cache — trading a bounded, transient re-parse cost on future calls
for eliminating the multi-GB permanent footprint. Verified against the real 2.5GB dataset
(same repro as the live crash): peak transient rss during a full all-time scan is ~933MB
(vs. ~3.8GB+ permanently held before), settling to ~263MB after GC. Global totals unchanged
(249M tokens, matching the pre-fix count) — correctness preserved, only retention changed.
342 tests (+2, TDD).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments