[BUG] RangeError: Invalid string length in CLI during command output processing

Resolved 💬 3 comments Opened Aug 7, 2025 by djfrancesco Closed Aug 8, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.70
  • Operating System: Linux 5.15.0-151-generic
  • Terminal: GNOME Terminal

Bug Description

Claude Code CLI crashes with a RangeError: Invalid string length when processing command output, likely when dealing with large amounts of data from stdout.

Steps to Reproduce

  1. well i was just asking questions about some code

Expected Behavior

The CLI should handle large command outputs gracefully without crashing.

Actual Behavior

The CLI crashes with the following error:
RangeError: Invalid string length
at Socket. (file:///home/francois/.nvm/versions/node/v22.16.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:824:2527)
at Socket.emit (node:events:530:35)
at Socket.emit (node:domain:489:12)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)

Node.js v22.16.0

Additional Context

The error occurs at line 824 in cli.js, in what appears to be a Socket data event handler. This suggests the issue is related to how the CLI processes stdout/stderr from executed commands, particularly when the output
is large. The stack trace indicates this is happening during stream processing, specifically when adding chunks to a readable stream.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗