[BUG] Claude Code crashes with RangeError: Invalid string length
Resolved 💬 3 comments Opened Sep 4, 2025 by ejstembler Closed Sep 8, 2025
Environment
- Platform (select one):
- [x] Anthropic API
- Claude CLI version: 1.0.105 (Claude Code)
- Operating System: macOS 15.6.1 (24G90)
- Terminal: Terminal in Zed Editor
Bug Description
Claude Code is running then crashes with this output:
file:///Users/my-user/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1452
- View comments on a Github PR: gh api repos/foo/bar/pulls/123/comments`}var Do2=A1(bK(),1);import{constants as rN6,readFileSync as oN6,existsSync as tN6}from"node:fs";var UH0=A1(bK(),1);function EH0(A){if(/\d\s*<<\s*\d/.test(A)||/\[\[\s*\d+\s*<<\s*\d+\s*\]\]/.test(A)||/\$\(\(.*<<.*\)\)/.test(A))return!1;return/<<-?\s*(?:(['"]?)(\w+)\1|\\(\w+))/.test(A)}function PN6(A){let B=/'(?:[^'\\]|\\.)*\n(?:[^'\\]|\\.)*'/,Q=/"(?:[^"\\]|\\.)*\n(?:[^"\\]|\\.)*"/;return B.test(A)||Q.test(A)}function Gy1(A,B=!0){if(EH0(A)||PN6(A)){let Z=`'${A.replace(/'/g,`'"'"'`)}'`;if(EH0(A))return Z;return B?`${Z} < /dev/null`:Z}if(B)return UH0.default.quote([A,"<","/dev/null"]);return UH0.default.quote([A])}function $H0(A){if(EH0(A))return!1;return!0}import{execSync as Co2,spawn as eN6}from"node:child_process";import{isAbsolute as AL6,resolve as BL6}from"node:path";import*as Uo2 from"node:os";import{PassThrough as jN6}from"stream";var rr2=A1(ir2(),1);class WZ1{capacity;buffer;head=0;size=0;constructor(A){this.capacity=A;this.buffer=new Array(A)}add(A){if(this.buffer[this.head]=A,this.head=(this.head+1)%this.capacity,this.size<this.capacity)this.size++}addAll(A){for(let B of A)this.add(B)}getRecent(A){let B=[],Q=this.size<this.capacity?0:this.head,Z=Math.min(A,this.size);for(let G=0;G<Z;G++){let Y=(Q+this.size-Z+G)%this.capacity;B.push(this.buffer[Y])}return B}toArray(){if(this.size===0)return[];let A=[],B=this.size<this.capacity?0:this.head;for(let Q=0;Q<this.size;Q++){let Z=(B+Q)%this.capacity;A.push(this.buffer[Z])}return A}clear(){this.head=0,this.size=0}length(){return this.size}}var nr2=137,ar2=143;function sr2(A){let B=null,Q="";A.on("data",(G)=>{if(B)B.write(G);else Q+=G});let Z=()=>Q;return{get:Z,asStream(){return B=new jN6({highWaterMark:10485760}),B.write(Z()),Q="",B}}}function or2(A,B,Q,Z){let G="running",Y,I=sr2(A.stdout),W=sr2(A.stderr);if(Z){let K=new WZ1(10),H=0,z=(D)=>{let w=D.toString().split(`
RangeError: Invalid string length
at Socket.<anonymous> (file:///Users/my-user/.asdf/installs/nodejs/24.1.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1452:1678)
at Socket.emit (node:events:519:35)
at Socket.emit (node:domain:489:12)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)
Node.js v24.1.0
Steps to Reproduce
- Claude Code is working on a task
- Claude Code crashes
Expected Behavior
Expected to continue working on task and not crash
Actual Behavior
It crashes
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗