VS Code: Corrupted session file causes unrecoverable crash loop (exit code 1)
Bug Description
A corrupted/large session .jsonl file causes Claude Code to crash immediately on startup in VS Code, creating an unrecoverable crash loop. The extension auto-resumes the last session on every restart, hitting the same bug repeatedly with no way for the user to escape without manually renaming the session file.
Environment
- Claude Code: v2.1.71 (VS Code extension)
- OS: Windows 11 Home 10.0.26200
- Node.js: v24.14.0
- 16 MCP servers configured
Steps to Reproduce
- Have a large session file (~2.7MB
.jsonl) - Open VS Code — extension auto-resumes the session
- Send any message
- Extension crashes with
TypeError: undefined is not an object (evaluating 'gH(M).length') - VS Code shows error:
Claude Code process exited with code 1 - Re-opening Claude Code panel or restarting VS Code always resumes the same broken session → crash loop
Error from Logs
2026-03-08T14:06:16.459Z [ERROR] "TypeError: TypeError: undefined is not an object (evaluating 'gH(M).length')
at <anonymous> (B:/~BUN/root/src/entrypoints/cli.js:1696:12340)
at reduce (native:1:11)
at Z4 (B:/~BUN/root/src/entrypoints/cli.js:1696:12317)
at processTicksAndRejections (native:7:39)"
Followed immediately by:
[error] Error from Claude (on channel uids0di0cdj): Error: Claude Code process exited with code 1
Crash Loop Evidence
The same session (68a02f9d-...) was auto-resumed across 5 VS Code restarts and 11+ channel crashes, all hitting the identical TypeError:
Session 1 (15:05): 7 channel crashes, all exit code 1
Session 2 (15:39): crash on resume
Session 3 (15:48): crash on resume
Session 4 (15:58): crash on resume
Session 5 (16:10): crash on resume
Secondary Effect: API Rate Limiting
Each crash triggers MCP server reconnections and API calls. After 11+ rapid crashes, Anthropic's own API started returning 429:
[clientData] fetch failed: 429
AxiosError: [url=https://api.anthropic.com/api/oauth/claude_cli/client_data,status=429,body=Rate limited.]
This made subsequent startups even worse — settings failed to load on top of the session bug.
Workaround
Manually rename the corrupted session file:
mv ~/.claude/projects/<project>/68a02f9d-*.jsonl ~/.claude/projects/<project>/68a02f9d-*.jsonl.bak
After this, VS Code starts a fresh session and works normally.
Suggested Fixes
- Graceful session recovery: If resuming a session throws, catch the error and start a fresh session instead of crashing
- Crash loop detection: If the same session crashes N times (e.g., 3), stop auto-resuming it
- Backoff on API calls: Don't hammer
client_dataendpoint on every restart — use exponential backoff when rate-limited - User-visible error: Show "Session could not be resumed" in the UI instead of silently crashing
Diagnostic Context
- The session file was 2.7MB (large but not extreme)
- The crash happens in minified code (
cli.js:1696) at what appears to be a.lengthaccess on an undefined value during message processing - All MCP servers connected successfully before the crash — the bug is in session/message handling, not MCP initialization
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗