RangeError: Maximum call stack size exceeded in endOfWORD() - CLI crashes with long outputs
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?
Claude Code CLI (v2.0.10) crashes with stack overflow when AI generates responses longer than ~15,000 characters due to infinite recursion in the
endOfWORD() function.
## Environment
- Claude Code Version: 2.0.10
- Node.js Version: v22.17.0
- NPM Version: 10.9.2
- OS: WSL2 - Ubuntu 24.04.2 LTS
- Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
- Platform: x86_64
- Terminal: xterm-256color
## Stack Trace
RangeError: Maximum call stack size exceeded
at U8.isOverWhitespace (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:820:399)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1741)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
[... infinite recursion continues ...]
## Steps to Reproduce
- Open Claude Code CLI (v2.0.10)
- Ask AI to analyze a large file line by line (e.g., "Read banca_global.py line by line - 610 lines")
- AI starts generating detailed analysis response
- When output reaches ~15,000-20,000 characters
- CLI attempts to render the text
endOfWORD()function enters infinite recursion- Stack overflow occurs → CLI crashes
- Terminal disconnects, all context lost
## Expected Behavior
CLI should render long responses without crashing, even with 50,000+ characters. Other terminal tools (vim, less, cat) handle massive outputs without
issues.
## Actual Behavior
CLI crashes and disconnects after ~15,000 characters of output, losing all conversation context and forcing restart.
## Impact
Severity: High
Frequency: Consistently reproducible
Problems Caused:
- Loss of conversation context (hours of work lost)
- Inability to analyze large files
- Severely degraded user experience for professional code analysis
- Need for manual workarounds
## Current Workaround
Instructing AI (via prompt engineering) to generate structured analysis instead of literal line-by-line citations, keeping output <15,000 characters
per response.
This works, but:
- Depends on AI awareness of the bug
- Not sustainable long-term
- Limits product functionality
## Additional Information
I have a 15MB log file (91,961 lines) documenting 14+ consecutive crashes from this bug. Available for analysis if needed.
## Suggested Fix
- Add maximum recursion limit in
endOfWORD() - Implement fallback when recursion exceeds limit
- Optimize word-wrap algorithm for edge cases
- Add buffer protection before stack overflow
- Alternative: Implement automatic pagination for large outputs
I'm available to provide complete logs, reproducible test cases, and beta testing for potential fixes.
Thank you for looking into this! This bug significantly impacts usability for professional development workflows.
What Should Happen?
CLI should render AI responses of any length without crashing. Terminal should remain stable even when processing 50,000+ character outputs, similar
to how other terminal tools (vim, less, cat) handle large text without issues.
Error Messages/Logs
RangeError: Maximum call stack size exceeded
at U8.isOverWhitespace (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:820:399)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1741)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
at U8.endOfWORD (file:///home/jeffelix/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js:818:1834)
[recursion continues infinitely until stack overflow]
Script done.
Steps to Reproduce
- Open Claude Code CLI v2.0.10 in terminal
- Start a conversation with the AI
- Ask: "Please analyze this file line by line: banca_global.py (610 lines)"
- AI begins generating detailed line-by-line analysis
- When AI response reaches approximately 15,000-20,000 characters
- CLI attempts to render the output
- The endOfWORD() function in cli.js enters infinite recursion
- Stack overflow occurs
- Terminal crashes with "Maximum call stack size exceeded"
- All conversation context is lost, requiring CLI restart
Note: Bug occurs consistently when AI generates responses longer than ~15k characters, regardless of file type or content being analyzed.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
Unknown - issue exists in current version
Claude Code Version
2.0.10 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
PowerShell
Additional Information
Selecione: Linux
E adicione no campo de texto:
WSL2 - Ubuntu 24.04.2 LTS (Kernel 6.6.87.2-microsoft-standard-WSL2)
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗