RangeError: Maximum call stack size exceeded in message streaming
Bug Description
Claude Code crashes with a RangeError: Maximum call stack size exceeded error during normal operation. The error occurs in the CLI's message streaming/event handling code.
Error Message
file:///<user-home>/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:496
`);B.enqueue(Y)}catch(G){B.error(G)}},async cancel(){await Q.return?.()}})}}});var A01=w(()=>{He1()});function De1(A,Q){if(!Q||!("parse"in(Q.output_format??{})))return{...A,content:A.content.map((B)=>{if(B.type==="text")return{...B,parsed:null};return B}),parsed_output:null};return Fe1(A,Q)}...
RangeError: Maximum call stack size exceeded
Environment
- OS: macOS (Darwin 24.5.0)
- Platform: darwin
Steps to Reproduce
The crash occurred during normal Claude Code operation. The specific trigger is unclear, but it appears to happen during message streaming/response processing.
Expected Behavior
Claude Code should handle message streaming without stack overflow errors.
Actual Behavior
The CLI crashes with RangeError: Maximum call stack size exceeded, preventing completion of the operation.
Analysis
The error appears to originate in the _QA class which handles message streaming, event emission, and async iteration. The stack overflow suggests either:
- Deeply nested recursive calls in the event handling chain
- An infinite loop in message/event processing
- Circular references in the streaming state machine
Additional Context
The affected code handles core functionality including:
- Message streaming (
_fromReadableStream,_createMessage) - Event emission (
_emit, event listeners) - Async iteration (
Symbol.asyncIterator) - Content block processing
This is a blocking issue that prevents normal CLI usage.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗