`--resume` picker crashes on corrupt sessions (ZstdDecompressionError), cascading to session index data loss
Environment: Windows 11, MSYS2 Git Bash, Claude Code v2.1.34–v2.1.37
Bug
When claude --resume scans sessions for the picker, it encounters sessions with embedded binary/compressed data and throws ZstdDecompressionError, causing an immediate exit. This crash can leave sessions-index.json in a partially-written state, causing subsequent launches to show dramatically fewer sessions.
Reproduction
- Have multiple sessions in a project directory, some of which crashed mid-write (common on Windows due to #22970 TUI instability)
- Run
claude --resume - Picker begins loading → hits a corrupt
.jsonlfile with embedded binary data →ZstdDecompressionError→ Claude exits immediately - Run
claude --resumeagain → session count is now much lower (e.g., 146 → 22 → 10)
Root cause
Some .jsonl session files contain embedded binary/null bytes (likely from crashes during context compression). When the --resume picker tries to deserialize these, zstd decompression fails. The crash during index scanning leaves sessions-index.json truncated.
Impact
--resumebecomes unreliable — exits before showing the picker- Session index loses entries on each crash (fluctuating session counts)
- Recent sessions "disappear" from the picker despite
.jsonlfiles being intact on disk - Users lose the ability to discover and resume their sessions
Workaround
Identified and quarantined 14 corrupt session files (containing \x00 or replacement characters) by removing them from sessions-index.json. This stopped the crashes and stabilized the index.
Suggested fix
The --resume picker should catch ZstdDecompressionError per-session rather than crashing entirely. Corrupt sessions should be skipped (or flagged) instead of terminating the picker. The index write should also be atomic (write to temp file, then rename) to prevent truncation on crash.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗