[BUG] /resume crashes with "_.reduce is not a function" on large sessions (~2.7 MB, 1015 entries)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Running /resume <session-id> on a large session (2.7 MB, 1015 JSONL entries) crashes with a JavaScript runtime error instead of loading the conversation.
Error
ERROR _.reduce is not a function. (In '_.reduce((T,q)=>{if(sf7(q))return T+yK(q.text);else if(tf7(q))return T+G0T;return T},0)', '_.reduce' is undefined)
/$bunfs/root/src/entrypoints/cli.js:2530:1772
Just before the crash, the CLI outputs:
[OUTPUT TRUNCATED - exceeded ${k0T()} token limit]
The ${k0T()} template literal is not interpolated — it appears verbatim, suggesting the truncation message itself is malformed or the truncation path doesn't evaluate the token-limit function before building the message.
After the OUTPUT TRUNCATED line, a stack trace of minified function names follows:
- JCq (/$bunfs/root/src/entrypoints/cli.js:2530:1772)
- hZT (/$bunfs/root/src/entrypoints/cli.js:2741:36165)
- v27 (/$bunfs/root/src/entrypoints/cli.js:2772:44388)
- MA (/$bunfs/root/src/entrypoints/cli.js:680:20992)
- z5 (/$bunfs/root/src/entrypoints/cli.js:680:39537)
- w7 (/$bunfs/root/src/entrypoints/cli.js:680:50227)
- KUT (/$bunfs/root/src/entrypoints/cli.js:680:86958)
- nt_ (/$bunfs/root/src/entrypoints/cli.js:680:85919)
- dn (/$bunfs/root/src/entrypoints/cli.js:680:85740)
- dv_ (/$bunfs/root/src/entrypoints/cli.js:680:82483)
Suspected Root Cause
The session history exceeds the internal token limit during replay. The truncation produces an unexpected type (likely undefined instead of an array), and the subsequent .reduce() call fails because it's called on a non-iterable value.
The uninterpolated ${k0T()} in the truncation message suggests the error path may be using a raw template string instead of evaluating it.
Session Diagnostics
| Metric | Value |
|--------|-------|
| File size | 2,823,622 bytes (2.7 MB) |
| Total JSONL entries | 1,015 |
| Conversation messages (user + assistant) | 513 |
| Tool use / tool result pairs | 195 |
| Compactions | 0 |
| First entry type | progress (not summary) |
| Entry type breakdown | progress: 431, user: 223, assistant: 290, system: 36, file-history-snapshot: 24, queue-operation: 10, last-prompt: 1 |
Note: the first entry is progress, not summary — this may also contribute to the issue (cf. #29467 which crashed on missing summary headers, though that was a different error).
Steps to Reproduce
- Accumulate a long session (~1000+ entries, ~2.7 MB JSONL) through normal extended use
- End the session
- Run
/resume <session-id>orclaude --resume <session-id> - CLI crashes with the
_.reduceerror above
Expected Behaviour
The session should either:
- Resume successfully (with older messages compacted/summarised to fit within limits), or
- Fail gracefully with a clear message like "Session too large to resume (2.7 MB, 1015 entries). Consider starting a new session."
Environment
- Claude Code version: 2.1.80
- OS: macOS (Darwin 25.3.0)
- Shell: PowerShell 7 (pwsh)
- Model at time of session: Sonnet 4.6 (1M context) via AWS Bedrock
Related Issues
- #31328 — Session unresumable after JSONL writer drops assistant entry (same symptom: large session can't resume; different root cause)
- #29467 — Resume crashes with
reading 'trim'(similar pattern: crash in minified CLI JS during resume; different error, now closed)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗