RangeError on Large Output

Status Closed — not planned
Maintainer reply ✓ Yes — bcherny
Activity 11 comments · opened Jul 28, 2025 · closed Jan 4, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

Summary

Claude Code CLI crashes with RangeError: Invalid string length when examining databases that return large amounts of output data.

Environment

  • Claude Code CLI Version: Latest (based on Node.js v20.18.1)
  • Platform: Linux 6.14.0-24-generic
  • Node.js Version: v20.18.1

Bug Description

When running database examination commands that produce large output (particularly database status checks), Claude Code crashes with a JavaScript string length error instead of gracefully handling the large data.

Error Details

RangeError: Invalid string length
    at Socket.<anonymous> (file:///home/sadara/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:780:8787)
    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:191:23)

Steps to Reproduce

  1. Have a Python script that queries databases and outputs large amounts of data
  2. Run the script through Claude Code CLI
  3. When the output exceeds JavaScript's maximum string length (~2^28 characters), the CLI crashes

Expected Behavior

Claude Code should handle large outputs gracefully by either:

  • Streaming the output in chunks
  • Truncating very large outputs with a warning
  • Implementing pagination for large datasets
  • Providing a configuration option for maximum output size

Actual Behavior

Claude Code crashes with RangeError: Invalid string length and terminates the session.

Impact

  • Severity: High
  • Frequency: Reproducible when working with database operations that return large datasets
  • Workaround: Manually limit output in user code (not ideal)

Technical Details

The error occurs in the CLI's output handling mechanism when trying to create a string that exceeds JavaScript's maximum string length limit. This appears to be in the socket data handling at line 780 of cli.js.

Suggested Fixes

  1. Implement streaming output: Instead of buffering all output into a single string, stream it in manageable chunks
  2. Add output size limits: Implement configurable limits on output size with graceful truncation
  3. Add pagination: For very large outputs, implement pagination or "show more" functionality
  4. Error handling: Catch RangeError exceptions and provide a user-friendly message instead of crashing

Files Affected

  • /home/sadara/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:780
  • Output handling/buffering mechanism in Claude Code CLI

Test Case

Create a Python script that outputs a very large string (>500MB) to reproduce the issue:

# This will crash Claude Code CLI
print("x" * (500 * 1024 * 1024))  # 500MB string

Additional Context

This issue was discovered while working with database management scripts that query multiple databases and return comprehensive status information. The crash log was saved to claude-crashlog.txt in the working directory.

Priority

This should be considered a high-priority bug as it affects the reliability of Claude Code when working with data-intensive applications, which is a common use case for development tools.

View original on GitHub ↗

11 Comments

bcherny collaborator · 1 year ago

Hi! How exactly did you pass the long string into Claude Code:

  • Were you piping into -p mode?
  • Did Claude Code decide to run the bash command itself?
  • When exactly did you see this crash?

Would love to see a screenshot of the crash, including the content right before it crashed.

iMartzen · 1 year ago

Since yesterday, I’ve had the same thing happen a few times. I didn’t use a long string in Claude’s code, just a regular prompt.

Total cost:            $0.3062
Total duration (API):  1m 26.5s
Total duration (wall): 55m 20.6s
Total code changes:    0 lines added, 0 lines removed

Prompt example:

I want to add an X to this MR to separate the business logic from the X. As an example of the pattern I want to follow, take a look at MR #6129 — it shows a clean implementation of X being used for business logic separation.

Your task:
	•	Review the current MR and identify where business logic is embedded in the mutation.
	•	Propose a plan to extract that logic into a new interactor.
	•	Reference MR #XXXX for structure and naming.
	•	Create a detailed to-do list with:
	•	what to move,
	•	what to refactor,
	•	and any test updates needed.

Let me know if anything is unclear before you begin.
pirate · 1 year ago

I'm also seeing this on v1.0.65, heres a more complete debug log:

✶ Channelling… (145s · ⚒ 1.3k tokens · esc to interrupt)

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ >                                                                                                                                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ? for shortcuts


file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:779
`),D.add(A.uuid)}}async getAllTranscripts(){await this.loadAllSessions();let A=[...this.messages.values()],B=new Set(A.map((Q)=>Q.parentUuid));return A.filter((Q)=>!B.has(Q.uuid)).map((Q)=>this.getTranscript(Q)).filter((Q)=>Q.length)}getTranscript(A){let B=[],Q=A;while(Q)B.unshift(Q),Q=Q.parentUuid?this.messages.get(Q.parentUuid):void 0;return B}async getLastLog(A){let{messages:B}=await kZ0(A);if(B.size===0)return null;let D=Array.from(B.values()).sort((F,I)=>new Date(I.timestamp).getTime()-new Date(F.timestamp).getTime())[0];if(!D)return null;let Z=[],G=D;while(G)Z.unshift(G),G=G.parentUuid?B.get(G.parentUuid):void 0;return Z}getAllCheckpoints(A){let B=new Map,Q=A[A.length-1]?.sessionId;if(Q){let D=this.checkpoints.get(Q)?.values()||[];for(let Z of D){let G=Z.id??Z.commit;if(G)B.set(G,Z)}}return Array.from(B.values())}loadAllSessions=PA(async()=>{let A=Io(w51),B=b1();if(this.didLoad)return this;try{B.statSync(A)}catch{return this}let D=B.readdirSync(A).filter((G)=>G.isFile()&&G.name.endsWith(".jsonl")).map((G)=>Yo(A,G.name)),Z=await Promise.all(D.sort((G,F)=>{let I=B.statSync(G),Y=B.statSync(F);return I.mtime.getTime()-Y.mtime.getTime()}).map(async(G)=>{let F=LC(rc4(G,".jsonl"));if(!F)return{sessionId:F,sessionMessages:new Set};let I=new Map,Y=new Map,W=new Map;try{await B.stat(G);for(let J of await Er1(G))if(J.type==="user"||J.type==="assistant"||J.type==="attachment"||J.type==="system")I.set(J.uuid,J);else if(J.type==="summary"&&J.leafUuid)Y.set(J.leafUuid,J.summary);else if(J.type==="checkpoint"){let X=J.id??J.commit;if(X)W.set(X,J)}}catch{}return{sessionId:F,sessionMessages:I,summaries:Y,checkpoints:W}}));for(let{sessionId:G,sessionMessages:F,summaries:I,checkpoints:Y}of Z){if(!G)continue;for(let[W,J]of F.entries())this.messages.set(W,J);for(let[W,J]of I.entries())this.summaries.set(W,J);this.checkpoints.set(G,Array.from(Y.values()))}return this.didLoad=!0,this})}async function gR1(A){let B=e$2(A);return await rT().insertMessageChain(B),B[B.length-1]?.uuid||null}async function n$2(A){await rT().insertMessageChain(e$2(A),!0)}async function SZ0(A){await rT().insertCheckpoint(A)}async function a$2(){let A=rT();A.sessionFile=hR1()}function tc4(A){let B=A.find((Z)=>Z.type==="user");if(!B||B.type!=="user")return"No prompt";let Q=B.message?.content,D="";if(typeof Q==="string")D=Q;else if(Array.isArray(Q))D=Q.find((G)=>G.type==="text")?.text||"No prompt";else D="No prompt";if(D=D.replace(/\n/g," ").trim(),D.length>45)D=D.slice(0,45)+"...";return D}function ec4(A){return A.map((B)=>{let{isSidechain:Q,parentUuid:D,...Z}=B;return Z})}function s$2(A,B=0,Q,D){let Z=A[A.length-1],G=A[0],F=tc4(A),I=new Date(G.timestamp),Y=new Date(Z.timestamp),W=D?.map((J)=>({id:J.id??"unavailable",commit:J.commit,timestamp:new Date(J.timestamp),label:J.label}));return{date:Z.timestamp,messages:ec4(A),fullPath:"n/a",value:B,created:I,modified:Y,firstPrompt:F,messageCount:A.length,isSidechain:G.isSidechain,leafUuid:Z.uuid,summary:Q,checkpoints:W,gitBranch:Z.gitBranch}}async function r$2(){let A=await rT().getAllTranscripts(),B=rT().summaries;return A.map((Q,D)=>{let Z=Q[Q.length-1],G=Z?B.get(Z.uuid):void 0,F=Z?rT().getAllCheckpoints(Q):void 0;return s$2(Q,D,G,F)}).sort((Q,D)=>{return D.modified.getTime()-Q.modified.getTime()})}async function o$2(A,B){await rT().appendEntry({type:"summary",summary:B,leafUuid:A})}async function jZ0(A){let B=new Map,Q=new Map,D=new Map;try{let Z=await Er1(A);for(let G of Z)if(G.type==="user"||G.type==="assistant"||G.type==="attachment"||G.type==="system")B.set(G.uuid,G);else if(G.type==="summary"&&G.leafUuid)Q.set(G.leafUuid,G.summary);else if(G.type==="checkpoint"){let F=G.id??G.commit;if(F)D.set(F,G)}}catch{}return{messages:B,summaries:Q,checkpoints:D}}async function kZ0(A){let B=Yo(Io(r0()),`${A}.jsonl`);return jZ0(B)}var Al4=PA(async(A)=>{let{messages:B,checkpoints:Q}=await kZ0(A);return{messageSet:new Set(B.keys()),checkpointSet:new Set(Q.keys())}},(A)=>A);async function t$2(A){let B=await rT().getLastLog(A);if(B!==null&&B!==void 0){let Q=B[B.length-1],{summaries:D,checkpoints:Z}=await kZ0(A),G=Q?D.get(Q.uuid):void 0;return s$2(B,0,G,Array.from(Z.values()))}return null}function e$2(A){return A.filter((B)=>{if(B.type==="progress")return!1;if(B.type==="attachment"&&p$2()!=="ant")return!1;return!0})}var uR1=[],Ql4=100;function Dl4(A){return A.toISOString().replace(/[:.]/g,"-")}var xZ0=Dl4(new Date);function Zl4(){return _Z0(SN.errors(),xZ0+".txt")}var yZ0=!1;function k1(A){if(yZ0)return;yZ0=!0;try{if(process.env.CLAUDE_CODE_USE_BEDROCK||process.env.CLAUDE_CODE_USE_VERTEX||process.env.DISABLE_ERROR_REPORTING||process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC)return;if(iQ(!1))console.error(A);let B=A.stack||A.message,Q={error:B,timestamp:new Date().toISOString()};if(uR1.length>=Ql4)uR1.shift();uR1.push(Q),Gl4(Zl4(),{error:B})}catch{}finally{yZ0=!1}fR1(A)}function Aq2(){return[...uR1]}function vZ0(A){if(!b1().existsSync(A))return[];try{return JSON.parse(b1().readFileSync(A,{encoding:"utf8"}))}catch{return[]}}function Gl4(A,B){return}async function Wo(){let A=await r$2();return Fl4(A.filter((B)=>B.messages.length)).map((B,Q)=>({...B,value:Q}))}async function Bq2(A){return await t$2(A)}async function Qq2(A){return(await Wo())[A]||null}function Fl4(A){return A.sort((B,Q)=>{let D=Q.modified.getTime()-B.modified.getTime();if(D!==0)return D;let Z=Q.created.getTime()-B.created.getTime();if(Z!==0)return Z;return B.created.getTime()-Q.created.getTime()})}function rZ(A,B){if(E9(I0.red(`MCP server "${A}" ${B}`)),(b9()||{}).cleanupPeriodDays===0)return;try{let D=SN.mcpLogs(A),Z=B instanceof Error?B.stack||B.message:String(B),G=new Date().toISOString(),F=_Z0(D,xZ0+".txt");if(!b1().existsSync(D))b1().mkdirSync(D);if(!b1().existsSync(F))b1().writeFileSync(F,"[]",{encoding:"utf8",flush:!1});let I={error:Z,timestamp:G,sessionId:F9(),cwd:b1().cwd()},Y=vZ0(F);Y.push(I),b1().writeFileSync(F,JSON.stringify(Y,null,2),{encoding:"utf8",flush:!1})}catch{}}function FB(A,B){j0(`MCP server "${A}": ${B}`);try{let Q=SN.mcpLogs(A),D=new Date().toISOString(),Z=_Z0(Q,xZ0+".txt");if(!b1().existsSync(Q))b1().mkdirSync(Q);if(!b1().existsSync(Z))b1().writeFileSync(Z,"[]",{encoding:"utf8",flush:!1});let G={debug:B,timestamp:D,sessionId:F9(),cwd:b1().cwd()},F=vZ0(Z);F.push(G),b1().writeFileSync(Z,JSON.stringify(F,null,2),{encoding:"utf8",flush:!1})}catch{}}import*as yq2 from"node:os";import{PassThrough as Yl4}from"stream";function Du(A){if(A<60000){let Z=(A/1000).toFixed(1);return`${Z.endsWith(".0")?Z.slice(0,-2):Z}s`}let B=Math.floor(A/3600000),Q=Math.floor(A%3600000/60000),D=(A%60000/1000).toFixed(1);if(B>0)return`${B}h ${Q}m ${D}s`;if(Q>0)return`${Q}m ${D}s`;return`${D}s`}function VI(A){let B=A>=1000;return new Intl.NumberFormat("en",{notation:"compact",minimumFractionDigits:B?1:0,maximumFractionDigits:1}).format(A).toLowerCase()}function bZ0(A,B={}){let{style:Q="narrow",numeric:D="always",now:Z=new Date}=B,G=A.getTime()-Z.getTime(),F=Math.trunc(G/1000),I=[{unit:"year",seconds:31536000,shortUnit:"y"},{unit:"month",seconds:2592000,shortUnit:"mo"},{unit:"week",seconds:604800,shortUnit:"w"},{unit:"day",seconds:86400,shortUnit:"d"},{unit:"hour",seconds:3600,shortUnit:"h"},{unit:"minute",seconds:60,shortUnit:"m"},{unit:"second",seconds:1,shortUnit:"s"}];for(let{unit:W,seconds:J,shortUnit:X}of I)if(Math.abs(F)>=J){let V=Math.trunc(F/J);if(Q==="narrow"&&J<86400)return F<0?`${Math.abs(V)}${X} ago`:`in ${V}${X}`;return new Intl.RelativeTimeFormat("en",{style:"long",numeric:D}).format(V,W)}if(Q==="narrow")return F<=0?"0s ago":"in 0s";return new Intl.RelativeTimeFormat("en",{style:Q,numeric:D}).format(0,"second")}function fZ0(A,B={}){let{now:Q=new Date,...D}=B;if(A>Q)return bZ0(A,{...D,now:Q});return bZ0(A,{...D,numeric:"always",now:Q})}function Jo(A,B=!1){if(!A)return;let Q=new Date(A*1000),D=Q.getMinutes(),Z=Q.toLocaleTimeString("en-US",{hour:"numeric",minute:D===0?void 0:"2-digit",hour12:!0}),G=Intl.DateTimeFormat().resolvedOptions().timeZone;return Z.replace(/ ([AP]M)/i,(F,I)=>I.toLowerCase())+(B?` (${G})`:"")}var Vq2=F1(Yq2(),1);class gZ0{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,D=Math.min(A,this.size);for(let Z=0;Z<D;Z++){let G=(Q+this.size-D+Z)%this.capacity;B.push(this.buffer[G])}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 D=(B+Q)%this.capacity;A.push(this.buffer[D])}return A}clear(){this.head=0,this.size=0}length(){return this.size}}var Wq2=137,Jq2=143;function Xq2(A){let B=null,Q="";A.on("data",(Z)=>{if(B)B.write(Z);else Q+=Z});let D=()=>Q;return{get:D,asStream(){return B=new Yl4({highWaterMark:10485760}),B.write(D()),Q="",B}}}function Kq2(A,B,Q,D){let Z="running",G,F=Xq2(A.stdout),I=Xq2(A.stderr);if(D){let V=new gZ0(10),K=0,C=(H)=>{let $=H.toString().split(`


RangeError: Invalid string length
    at Socket.<anonymous> (file:///opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/cli.js:779:8787)
    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.2.0
Civil · 1 year ago

I have same issue. In my case Claude Code decided to run a bash command (compiled code it produced) and because of a bug it produced roughly 1543765 lines:

file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:779
`),D.add(A.uuid)}}async getAllTranscripts(){await this.loadAllSessions();let A=[...this.messages.values()],B=new Set(A.map((Q)=>Q.parentUuid));return A.filter((Q)=>!B.has(Q.uuid)).map((Q)=>this.getTranscript(Q)).filter((Q)=>Q.length)}getTranscript(A){let B=[],Q=A;while(Q)B.unshift(Q),Q=Q.parentUuid?this.messages.get(Q.parentUuid):void 0;return B}async getLastLog(A){let{messages:B}=await kZ0(A);if(B.size===0)return null;let D=Array.from(B.values()).sort((F,I)=>new Date(I.timestamp).getTime()-new Date(F.timestamp).getTime())[0];if(!D)return null;let Z=[],G=D;while(G)Z.unshift(G),G=G.parentUuid?B.get(G.parentUuid):void 0;return Z}getAllCheckpoints(A){let B=new Map,Q=A[A.length-1]?.sessionId;if(Q){let D=this.checkpoints.get(Q)?.values()||[];for(let Z of D){let G=Z.id??Z.commit;if(G)B.set(G,Z)}}return Array.from(B.values())}loadAllSessions=PA(async()=>{let A=Io(w51),B=b1();if(this.didLoad)return this;try{B.statSync(A)}catch{return this}let D=B.readdirSync(A).filter((G)=>G.isFile()&&G.name.endsWith(".jsonl")).map((G)=>Yo(A,G.name)),Z=await Promise.all(D.sort((G,F)=>{let I=B.statSync(G),Y=B.statSync(F);return I.mtime.getTime()-Y.mtime.getTime()}).map(async(G)=>{let F=LC(rc4(G,".jsonl"));if(!F)return{sessionId:F,sessionMessages:new Set};let I=new Map,Y=new Map,W=new Map;try{await B.stat(G);for(let J of await Er1(G))if(J.type==="user"||J.type==="assistant"||J.type==="attachment"||J.type==="system")I.set(J.uuid,J);else if(J.type==="summary"&&J.leafUuid)Y.set(J.leafUuid,J.summary);else if(J.type==="checkpoint"){let X=J.id??J.commit;if(X)W.set(X,J)}}catch{}return{sessionId:F,sessionMessages:I,summaries:Y,checkpoints:W}}));for(let{sessionId:G,sessionMessages:F,summaries:I,checkpoints:Y}of Z){if(!G)continue;for(let[W,J]of F.entries())this.messages.set(W,J);for(let[W,J]of I.entries())this.summaries.set(W,J);this.checkpoints.set(G,Array.from(Y.values()))}return this.didLoad=!0,this})}async function gR1(A){let B=e$2(A);return await rT().insertMessageChain(B),B[B.length-1]?.uuid||null}async function n$2(A){await rT().insertMessageChain(e$2(A),!0)}async function SZ0(A){await rT().insertCheckpoint(A)}async function a$2(){let A=rT();A.sessionFile=hR1()}function tc4(A){let B=A.find((Z)=>Z.type==="user");if(!B||B.type!=="user")return"No prompt";let Q=B.message?.content,D="";if(typeof Q==="string")D=Q;else if(Array.isArray(Q))D=Q.find((G)=>G.type==="text")?.text||"No prompt";else D="No prompt";if(D=D.replace(/\n/g," ").trim(),D.length>45)D=D.slice(0,45)+"...";return D}function ec4(A){return A.map((B)=>{let{isSidechain:Q,parentUuid:D,...Z}=B;return Z})}function s$2(A,B=0,Q,D){let Z=A[A.length-1],G=A[0],F=tc4(A),I=new Date(G.timestamp),Y=new Date(Z.timestamp),W=D?.map((J)=>({id:J.id??"unavailable",commit:J.commit,timestamp:new Date(J.timestamp),label:J.label}));return{date:Z.timestamp,messages:ec4(A),fullPath:"n/a",value:B,created:I,modified:Y,firstPrompt:F,messageCount:A.length,isSidechain:G.isSidechain,leafUuid:Z.uuid,summary:Q,checkpoints:W,gitBranch:Z.gitBranch}}async function r$2(){let A=await rT().getAllTranscripts(),B=rT().summaries;return A.map((Q,D)=>{let Z=Q[Q.length-1],G=Z?B.get(Z.uuid):void 0,F=Z?rT().getAllCheckpoints(Q):void 0;return s$2(Q,D,G,F)}).sort((Q,D)=>{return D.modified.getTime()-Q.modified.getTime()})}async function o$2(A,B){await rT().appendEntry({type:"summary",summary:B,leafUuid:A})}async function jZ0(A){let B=new Map,Q=new Map,D=new Map;try{let Z=await Er1(A);for(let G of Z)if(G.type==="user"||G.type==="assistant"||G.type==="attachment"||G.type==="system")B.set(G.uuid,G);else if(G.type==="summary"&&G.leafUuid)Q.set(G.leafUuid,G.summary);else if(G.type==="checkpoint"){let F=G.id??G.commit;if(F)D.set(F,G)}}catch{}return{messages:B,summaries:Q,checkpoints:D}}async function kZ0(A){let B=Yo(Io(r0()),`${A}.jsonl`);return jZ0(B)}var Al4=PA(async(A)=>{let{messages:B,checkpoints:Q}=await kZ0(A);return{messageSet:new Set(B.keys()),checkpointSet:new Set(Q.keys())}},(A)=>A);async function t$2(A){let B=await rT().getLastLog(A);if(B!==null&&B!==void 0){let Q=B[B.length-1],{summaries:D,checkpoints:Z}=await kZ0(A),G=Q?D.get(Q.uuid):void 0;return s$2(B,0,G,Array.from(Z.values()))}return null}function e$2(A){return A.filter((B)=>{if(B.type==="progress")return!1;if(B.type==="attachment"&&p$2()!=="ant")return!1;return!0})}var uR1=[],Ql4=100;function Dl4(A){return A.toISOString().replace(/[:.]/g,"-")}var xZ0=Dl4(new Date);function Zl4(){return _Z0(SN.errors(),xZ0+".txt")}var yZ0=!1;function k1(A){if(yZ0)return;yZ0=!0;try{if(process.env.CLAUDE_CODE_USE_BEDROCK||process.env.CLAUDE_CODE_USE_VERTEX||process.env.DISABLE_ERROR_REPORTING||process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC)return;if(iQ(!1))console.error(A);let B=A.stack||A.message,Q={error:B,timestamp:new Date().toISOString()};if(uR1.length>=Ql4)uR1.shift();uR1.push(Q),Gl4(Zl4(),{error:B})}catch{}finally{yZ0=!1}fR1(A)}function Aq2(){return[...uR1]}function vZ0(A){if(!b1().existsSync(A))return[];try{return JSON.parse(b1().readFileSync(A,{encoding:"utf8"}))}catch{return[]}}function Gl4(A,B){return}async function Wo(){let A=await r$2();return Fl4(A.filter((B)=>B.messages.length)).map((B,Q)=>({...B,value:Q}))}async function Bq2(A){return await t$2(A)}async function Qq2(A){return(await Wo())[A]||null}function Fl4(A){return A.sort((B,Q)=>{let D=Q.modified.getTime()-B.modified.getTime();if(D!==0)return D;let Z=Q.created.getTime()-B.created.getTime();if(Z!==0)return Z;return B.created.getTime()-Q.created.getTime()})}function rZ(A,B){if(E9(I0.red(`MCP server "${A}" ${B}`)),(b9()||{}).cleanupPeriodDays===0)return;try{let D=SN.mcpLogs(A),Z=B instanceof Error?B.stack||B.message:String(B),G=new Date().toISOString(),F=_Z0(D,xZ0+".txt");if(!b1().existsSync(D))b1().mkdirSync(D);if(!b1().existsSync(F))b1().writeFileSync(F,"[]",{encoding:"utf8",flush:!1});let I={error:Z,timestamp:G,sessionId:F9(),cwd:b1().cwd()},Y=vZ0(F);Y.push(I),b1().writeFileSync(F,JSON.stringify(Y,null,2),{encoding:"utf8",flush:!1})}catch{}}function FB(A,B){j0(`MCP server "${A}": ${B}`);try{let Q=SN.mcpLogs(A),D=new Date().toISOString(),Z=_Z0(Q,xZ0+".txt");if(!b1().existsSync(Q))b1().mkdirSync(Q);if(!b1().existsSync(Z))b1().writeFileSync(Z,"[]",{encoding:"utf8",flush:!1});let G={debug:B,timestamp:D,sessionId:F9(),cwd:b1().cwd()},F=vZ0(Z);F.push(G),b1().writeFileSync(Z,JSON.stringify(F,null,2),{encoding:"utf8",flush:!1})}catch{}}import*as yq2 from"node:os";import{PassThrough as Yl4}from"stream";function Du(A){if(A<60000){let Z=(A/1000).toFixed(1);return`${Z.endsWith(".0")?Z.slice(0,-2):Z}s`}let B=Math.floor(A/3600000),Q=Math.floor(A%3600000/60000),D=(A%60000/1000).toFixed(1);if(B>0)return`${B}h ${Q}m ${D}s`;if(Q>0)return`${Q}m ${D}s`;return`${D}s`}function VI(A){let B=A>=1000;return new Intl.NumberFormat("en",{notation:"compact",minimumFractionDigits:B?1:0,maximumFractionDigits:1}).format(A).toLowerCase()}function bZ0(A,B={}){let{style:Q="narrow",numeric:D="always",now:Z=new Date}=B,G=A.getTime()-Z.getTime(),F=Math.trunc(G/1000),I=[{unit:"year",seconds:31536000,shortUnit:"y"},{unit:"month",seconds:2592000,shortUnit:"mo"},{unit:"week",seconds:604800,shortUnit:"w"},{unit:"day",seconds:86400,shortUnit:"d"},{unit:"hour",seconds:3600,shortUnit:"h"},{unit:"minute",seconds:60,shortUnit:"m"},{unit:"second",seconds:1,shortUnit:"s"}];for(let{unit:W,seconds:J,shortUnit:X}of I)if(Math.abs(F)>=J){let V=Math.trunc(F/J);if(Q==="narrow"&&J<86400)return F<0?`${Math.abs(V)}${X} ago`:`in ${V}${X}`;return new Intl.RelativeTimeFormat("en",{style:"long",numeric:D}).format(V,W)}if(Q==="narrow")return F<=0?"0s ago":"in 0s";return new Intl.RelativeTimeFormat("en",{style:Q,numeric:D}).format(0,"second")}function fZ0(A,B={}){let{now:Q=new Date,...D}=B;if(A>Q)return bZ0(A,{...D,now:Q});return bZ0(A,{...D,numeric:"always",now:Q})}function Jo(A,B=!1){if(!A)return;let Q=new Date(A*1000),D=Q.getMinutes(),Z=Q.toLocaleTimeString("en-US",{hour:"numeric",minute:D===0?void 0:"2-digit",hour12:!0}),G=Intl.DateTimeFormat().resolvedOptions().timeZone;return Z.replace(/ ([AP]M)/i,(F,I)=>I.toLowerCase())+(B?` (${G})`:"")}var Vq2=F1(Yq2(),1);class gZ0{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,D=Math.min(A,this.size);for(let Z=0;Z<D;Z++){let G=(Q+this.size-D+Z)%this.capacity;B.push(this.buffer[G])}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 D=(B+Q)%this.capacity;A.push(this.buffer[D])}return A}clear(){this.head=0,this.size=0}length(){return this.size}}var Wq2=137,Jq2=143;function Xq2(A){let B=null,Q="";A.on("data",(Z)=>{if(B)B.write(Z);else Q+=Z});let D=()=>Q;return{get:D,asStream(){return B=new Yl4({highWaterMark:10485760}),B.write(D()),Q="",B}}}function Kq2(A,B,Q,D){let Z="running",G,F=Xq2(A.stdout),I=Xq2(A.stderr);if(D){let V=new gZ0(10),K=0,C=(H)=>{let $=H.toString().split(`


RangeError: Invalid string length
    at Socket.<anonymous> (file:///usr/local/lib/node_modules/@anthropic-ai/claude-code/cli.js:779:8787)
    at Socket.emit (node:events:529:35)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

It needs to filter the socket and at least close the socket if it exceeds certain limits.

jtjenkins · 1 year ago

I've had this happen as well on version 1.0.68 on MacOS with NodeJS v22.18.0.

Bash(node backend/debug-middleware.js)
  ⎿  }
     21:44:56 [info]: Prisma client disconnecting... {
       "service": "guild-track-backend",
       "version": "1.0.0"
     }
     +16270910 more lines (50s)

✶ Spelunking… (59s · ⚒ 58 tokens · esc to interrupt)

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ >                                                                                                                                    │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
  ? for shortcuts
file:///Users/jordan/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:823
`),Z.add(A.uuid)}}async getAllTranscripts(){await this.loadAllSessions();let A=[...this.messages.values()],B=new Set(A.map((Q)=>Q.parentUuid));return A.filter((Q)=>!B.has(Q.uuid)).map((Q)=>this.getTranscript(Q)).filter((Q)=>Q.length)}getTranscript(A){let B=[],Q=A;while(Q)B.unshift(Q),Q=Q.parentUuid?this.messages.get(Q.parentUuid):void 0;return B}async getLastLog(A){let{messages:B}=await _I0(A);if(B.size===0)return null;let Z=Array.from(B.values()).sort((F,Y)=>new Date(Y.timestamp).getTime()-new Date(F.timestamp).getTime())[0];if(!Z)return null;let D=[],G=Z;while(G)D.unshift(G),G=G.parentUuid?B.get(G.parentUuid):void 0;return D}getAllCheckpoints(A){let B=new Map,Q=A[A.length-1]?.sessionId;if(Q){let Z=this.checkpoints.get(Q)?.values()||[];for(let D of Z){let G=D.id??D.commit;if(G)B.set(G,D)}}return Array.from(B.values())}getBookmarkStatus(A){return this.bookmarks.get(A)?.isBookmarked??!1}loadAllSessions=PA(async()=>{let A=to(M31),B=b1();if(this.didLoad)return this;try{B.statSync(A)}catch{return this}let Z=B.readdirSync(A).filter((G)=>G.isFile()&&G.name.endsWith(".jsonl")).map((G)=>eo(A,G.name)),D=await Promise.all(Z.sort((G,F)=>{let Y=B.statSync(G),I=B.statSync(F);return Y.mtime.getTime()-I.mtime.getTime()}).map(async(G)=>{let F=_C(BQ6(G,".jsonl"));if(!F)return{sessionId:F,sessionMessages:new Set};let Y=new Map,I=new Map,W=new Map,J;try{await B.stat(G);for(let X of await U10(G))if(X.type==="user"||X.type==="assistant"||X.type==="attachment"||X.type==="system")Y.set(X.uuid,X);else if(X.type==="summary"&&X.leafUuid)I.set(X.leafUuid,X.summary);else if(X.type==="checkpoint"){let V=X.id??X.commit;if(V)W.set(V,X)}else if(X.type==="bookmark")J=X}catch{}return{sessionId:F,sessionMessages:Y,summaries:I,checkpoints:W,bookmarkStatus:J}}));for(let{sessionId:G,sessionMessages:F,summaries:Y,checkpoints:I,bookmarkStatus:W}of D){if(!G)continue;for(let[J,X]of F.entries())this.messages.set(J,X);for(let[J,X]of Y.entries())this.summaries.set(J,X);if(this.checkpoints.set(G,Array.from(I.values())),W)this.bookmarks.set(G,W)}return this.didLoad=!0,this})}async function JP1(A){let B=sS2(A);return await DM().insertMessageChain(B),B[B.length-1]?.uuid||null}async function cS2(A){await DM().insertMessageChain(sS2(A),!0)}async function kI0(A){await DM().insertCheckpoint(A)}async function lS2(){let A=DM();A.sessionFile=WP1()}function ZQ6(A){let B=A.find((D)=>D.type==="user");if(!B||B.type!=="user")return"No prompt";let Q=B.message?.content,Z="";if(typeof Q==="string")Z=Q;else if(Array.isArray(Q))Z=Q.find((G)=>G.type==="text")?.text||"No prompt";else Z="No prompt";if(Z=Z.replace(/\n/g," ").trim(),Z.length>45)Z=Z.slice(0,45)+"...";return Z}function DQ6(A){return A.map((B)=>{let{isSidechain:Q,parentUuid:Z,...D}=B;return D})}function pS2(A,B=0,Q,Z,D){let G=A[A.length-1],F=A[0],Y=ZQ6(A),I=new Date(F.timestamp),W=new Date(G.timestamp),J=Z?.map((X)=>({id:X.id??"unavailable",commit:X.commit,timestamp:new Date(X.timestamp),label:X.label}));return{date:G.timestamp,messages:DQ6(A),fullPath:"n/a",value:B,created:I,modified:W,firstPrompt:Y,messageCount:A.length,isSidechain:F.isSidechain,leafUuid:G.uuid,summary:Q,checkpoints:J,gitBranch:G.gitBranch,isBookmarked:D}}async function iS2(){let A=await DM().getAllTranscripts(),B=DM().summaries;return A.map((Q,Z)=>{let D=Q[Q.length-1],G=D?B.get(D.uuid):void 0,F=D?DM().getAllCheckpoints(Q):void 0,Y=D?.sessionId,I=Y?DM().getBookmarkStatus(Y):!1;return pS2(Q,Z,G,F,I)}).sort((Q,Z)=>{return Z.modified.getTime()-Q.modified.getTime()})}async function nS2(A,B){await DM().appendEntry({type:"summary",summary:B,leafUuid:A})}async function yI0(A){let B=new Map,Q=new Map,Z=new Map;try{let D=await U10(A);for(let G of D)if(G.type==="user"||G.type==="assistant"||G.type==="attachment"||G.type==="system")B.set(G.uuid,G);else if(G.type==="summary"&&G.leafUuid)Q.set(G.leafUuid,G.summary);else if(G.type==="checkpoint"){let F=G.id??G.commit;if(F)Z.set(F,G)}}catch{}return{messages:B,summaries:Q,checkpoints:Z}}async function _I0(A){let B=eo(to(o0()),`${A}.jsonl`);return yI0(B)}var GQ6=PA(async(A)=>{let{messages:B,checkpoints:Q}=await _I0(A);return{messageSet:new Set(B.keys()),checkpointSet:new Set(Q.keys())}},(A)=>A);async function aS2(A){let B=await DM().getLastLog(A);if(B!==null&&B!==void 0){let Q=B[B.length-1],{summaries:Z,checkpoints:D}=await _I0(A),G=Q?Z.get(Q.uuid):void 0;return pS2(B,0,G,Array.from(D.values()))}return null}function sS2(A){return A.filter((B)=>{if(B.type==="progress")return!1;if(B.type==="attachment"&&mS2()!=="ant")return!1;return!0})}var XP1=[],YQ6=100;function IQ6(A){return A.toISOString().replace(/[:.]/g,"-")}var bI0=IQ6(new Date);function WQ6(){return vI0(sN.errors(),bI0+".txt")}var xI0=!1;function T1(A){if(xI0)return;xI0=!0;try{if(process.env.CLAUDE_CODE_USE_BEDROCK||process.env.CLAUDE_CODE_USE_VERTEX||process.env.DISABLE_ERROR_REPORTING||process.env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC)return;if(g4(!1))console.error(A);let B=A.stack||A.message,Q={error:B,timestamp:new Date().toISOString()};if(XP1.length>=YQ6)XP1.shift();XP1.push(Q),JQ6(WQ6(),{error:B})}catch{}finally{xI0=!1}IP1(A)}function rS2(){return[...XP1]}function fI0(A){if(!b1().existsSync(A))return[];try{return JSON.parse(b1().readFileSync(A,{encoding:"utf8"}))}catch{return[]}}function JQ6(A,B){return}async function At(){let A=await iS2();return XQ6(A.filter((B)=>B.messages.length)).map((B,Q)=>({...B,value:Q}))}async function oS2(A){return await aS2(A)}async function tS2(A){return(await At())[A]||null}function XQ6(A){return A.sort((B,Q)=>{if(B.isBookmarked&&!Q.isBookmarked)return-1;if(!B.isBookmarked&&Q.isBookmarked)return 1;let Z=Q.modified.getTime()-B.modified.getTime();if(Z!==0)return Z;let D=Q.created.getTime()-B.created.getTime();if(D!==0)return D;return B.created.getTime()-Q.created.getTime()})}function GG(A,B){if(p2(A0.red(`MCP server "${A}" ${B}`)),(M9()||{}).cleanupPeriodDays===0)return;try{let Z=sN.mcpLogs(A),D=B instanceof Error?B.stack||B.message:String(B),G=new Date().toISOString(),F=vI0(Z,bI0+".txt");if(!b1().existsSync(Z))b1().mkdirSync(Z);if(!b1().existsSync(F))b1().writeFileSync(F,"[]",{encoding:"utf8",flush:!1});let Y={error:D,timestamp:G,sessionId:oB(),cwd:b1().cwd()},I=fI0(F);I.push(Y),b1().writeFileSync(F,JSON.stringify(I,null,2),{encoding:"utf8",flush:!1})}catch{}}function FB(A,B){C0(`MCP server "${A}": ${B}`);try{let Q=sN.mcpLogs(A),Z=new Date().toISOString(),D=vI0(Q,bI0+".txt");if(!b1().existsSync(Q))b1().mkdirSync(Q);if(!b1().existsSync(D))b1().writeFileSync(D,"[]",{encoding:"utf8",flush:!1});let G={debug:B,timestamp:Z,sessionId:oB(),cwd:b1().cwd()},F=fI0(D);F.push(G),b1().writeFileSync(D,JSON.stringify(F,null,2),{encoding:"utf8",flush:!1})}catch{}}import*as Rj2 from"node:os";import{PassThrough as KQ6}from"stream";function gu(A){if(A<60000){let D=(A/1000).toFixed(1);return`${D.endsWith(".0")?D.slice(0,-2):D}s`}let B=Math.floor(A/3600000),Q=Math.floor(A%3600000/60000),Z=(A%60000/1000).toFixed(1);if(B>0)return`${B}h ${Q}m ${Z}s`;if(Q>0)return`${Q}m ${Z}s`;return`${Z}s`}function UY(A){let B=A>=1000;return new Intl.NumberFormat("en",{notation:"compact",minimumFractionDigits:B?1:0,maximumFractionDigits:1}).format(A).toLowerCase()}function VP1(A,B={}){let{style:Q="narrow",numeric:Z="always",now:D=new Date}=B,G=A.getTime()-D.getTime(),F=Math.trunc(G/1000),Y=[{unit:"year",seconds:31536000,shortUnit:"y"},{unit:"month",seconds:2592000,shortUnit:"mo"},{unit:"week",seconds:604800,shortUnit:"w"},{unit:"day",seconds:86400,shortUnit:"d"},{unit:"hour",seconds:3600,shortUnit:"h"},{unit:"minute",seconds:60,shortUnit:"m"},{unit:"second",seconds:1,shortUnit:"s"}];for(let{unit:W,seconds:J,shortUnit:X}of Y)if(Math.abs(F)>=J){let V=Math.trunc(F/J);if(Q==="narrow"&&J<86400)return F<0?`${Math.abs(V)}${X} ago`:`in ${V}${X}`;return new Intl.RelativeTimeFormat("en",{style:"long",numeric:Z}).format(V,W)}if(Q==="narrow")return F<=0?"0s ago":"in 0s";return new Intl.RelativeTimeFormat("en",{style:Q,numeric:Z}).format(0,"second")}function KP1(A,B={}){let{now:Q=new Date,...Z}=B;if(A>Q)return VP1(A,{...Z,now:Q});return VP1(A,{...Z,numeric:"always",now:Q})}function Bt(A,B=!1){if(!A)return;let Q=new Date(A*1000),Z=Q.getMinutes(),D=Q.toLocaleTimeString("en-US",{hour:"numeric",minute:Z===0?void 0:"2-digit",hour12:!0}),G=Intl.DateTimeFormat().resolvedOptions().timeZone;return D.replace(/ ([AP]M)/i,(F,Y)=>Y.toLowerCase())+(B?` (${G})`:"")}var Ij2=F1(Dj2(),1);class gI0{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 D=0;D<Z;D++){let G=(Q+this.size-Z+D)%this.capacity;B.push(this.buffer[G])}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 Gj2=137,Fj2=143;function Yj2(A){let B=null,Q="";A.on("data",(D)=>{if(B)B.write(D);else Q+=D});let Z=()=>Q;return{get:Z,asStream(){return B=new KQ6({highWaterMark:10485760}),B.write(Z()),Q="",B}}}function Wj2(A,B,Q,Z){let D="running",G,F=Yj2(A.stdout),Y=Yj2(A.stderr);if(Z){let V=new gI0(10),K=0,C=(H)=>{let w=H.toString().split(`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

RangeError: Invalid string length
    at Socket.<anonymous> (file:///Users/jordan/.nvm/versions/node/v22.18.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:823:9106)
    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)
GordonMcGregor · 1 year ago

generate_logs.py.txt. (This is the python script to help with formatting)

Can confirm also seeing this in v1.0.68

Any output generator that generates more than 0x1fffffe8 characters to stdout overflows the string concat buffer capturing stdout around like 823 in cli.js

You can run this generator below . Save it to generate_logs.py, and run this prompt in CC

Run python generate_logs.py 600 and don't redirect the output to a file

That should recreate the failure. It'll generate a lot of 'pseudo-log' messages until it overflows the buffer and crashes.

`
#!/usr/bin/env python3
import sys
import random
import string
from datetime import datetime, timedelta

def generate_log_entry(timestamp, message_length=100):
levels = ['INFO', 'WARN', 'ERROR', 'DEBUG']
components = ['auth', 'database', 'api', 'cache', 'queue', 'scheduler', 'worker']

level = random.choice(levels)
component = random.choice(components)

random_message = ''.join(random.choices(string.ascii_letters + string.digits + ' .,-!?', k=message_length))

return f"[{timestamp.strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]}] {level:5} {component:10} - {random_message}\n"

def generate_logs(target_size_mb=500):
target_size_bytes = target_size_mb 1024 1024
current_size = 0

base_time = datetime.now() - timedelta(days=1)
entry_count = 0

batch_size = 1000
batch_data = []

while current_size < target_size_bytes:
for _ in range(batch_size):
timestamp = base_time + timedelta(milliseconds=entry_count * 100)
log_entry = generate_log_entry(timestamp)
batch_data.append(log_entry)
current_size += len(log_entry)
entry_count += 1

if current_size >= target_size_bytes:
break

sys.stdout.write(''.join(batch_data))
sys.stdout.flush()
batch_data.clear()

if __name__ == "__main__":
target_size = 500
if len(sys.argv) > 1:
try:
target_size = int(sys.argv[1])
except ValueError:
print(f"Invalid size argument: {sys.argv[1]}. Using default 500MB.", file=sys.stderr)

generate_logs(target_size)

`

github-actions[bot] · 1 year ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5377
  2. https://github.com/anthropics/claude-code/issues/4334
  3. https://github.com/anthropics/claude-code/issues/3654

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Ituking · 1 year ago

I also encountered the same issue.

Environment

  • 1.0.80 (Claude Code)
  • Node.js: v23.11.0 (installed via Homebrew)
  • OS: macOS 15.5
  • Context: Occurred during task execution in Claude Code CLI while running tests

Description
The error occurred during test execution (flutter test).
The CLI crashed with the following error:

file:///usr/local/Cellar/node/23.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1445
`);if(D!==-1){if(Z=A.substring(0,D),Z.length+1>B)return`${Z.substring(0,B-1)}…`;return`${Z}…`}}if(Z.length<=B)return Z;return`${Z.substring(0,B-1)}…`}function am(A){if(A<60000){let D=(A/1000).toFixed(1);return`${D.endsWith(".0")?D.slice(0,-2):D}s`}let B=Math.floor(A/3600000),Q=Math.floor(A%3600000/60000),Z=(A%60000/1000).toFixed(1);if(B>0)return`${B}h ${Q}m ${Z}s`;if(Q>0)return`${Q}m ${Z}s`;return`${Z}s`}function SI(A){let B=A>=1000;return new Intl.NumberFormat("en",{notation:"compact",minimumFractionDigits:B?1:0,maximumFractionDigits:1}).format(A).toLowerCase()}function Kv1(A,B={}){let{style:Q="narrow",numeric:Z="always",now:D=new Date}=B,G=A.getTime()-D.getTime(),F=Math.trunc(G/1000),I=[{unit:"year",seconds:31536000,shortUnit:"y"},{unit:"month",seconds:2592000,shortUnit:"mo"},{unit:"week",seconds:604800,shortUnit:"w"},{unit:"day",seconds:86400,shortUnit:"d"},{unit:"hour",seconds:3600,shortUnit:"h"},{unit:"minute",seconds:60,shortUnit:"m"},{unit:"second",seconds:1,shortUnit:"s"}];for(let{unit:W,seconds:J,shortUnit:X}of I)if(Math.abs(F)>=J){let V=Math.trunc(F/J);if(Q==="narrow"&&J<86400)return F<0?`${Math.abs(V)}${X} ago`:`in ${V}${X}`;return new Intl.RelativeTimeFormat("en",{style:"long",numeric:Z}).format(V,W)}if(Q==="narrow")return F<=0?"0s ago":"in 0s";return new Intl.RelativeTimeFormat("en",{style:Q,numeric:Z}).format(0,"second")}function Hv1(A,B={}){let{now:Q=new Date,...Z}=B;if(A>Q)return Kv1(A,{...Z,now:Q});return Kv1(A,{...Z,numeric:"always",now:Q})}function v11(A,B=!1){if(!A)return;let Q=new Date(A*1000),Z=Q.getMinutes(),D=Q.toLocaleTimeString("en-US",{hour:"numeric",minute:Z===0?void 0:"2-digit",hour12:!0}),G=Intl.DateTimeFormat().resolvedOptions().timeZone;return D.replace(/ ([AP]M)/i,(F,I)=>I.toLowerCase())+(B?` (${G})`:"")}var uLB=F1(bLB(),1);class BG1{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 D=0;D<Z;D++){let G=(Q+this.size-Z+D)%this.capacity;B.push(this.buffer[G])}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 fLB=137,hLB=143;function gLB(A){let B=null,Q="";A.on("data",(D)=>{if(B)B.write(D);else Q+=D});let Z=()=>Q;return{get:Z,asStream(){return B=new V48({highWaterMark:10485760}),B.write(Z()),Q="",B}}}function mLB(A,B,Q,Z){let D="running",G,F=gLB(A.stdout),I=gLB(A.stderr);if(Z){let V=new BG1(10),K=0,C=(H)=>{let $=H.toString().split(`


RangeError: Invalid string length
at Socket.<anonymous> (file:///usr/local/Cellar/node/23.11.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1445:2528)
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 v23.11.0

Steps to reproduce

  1. Run claude --continue
  2. During execution, run a Flutter test command with large output:
flutter test test/features/upload/presentation/pages/upload_page_test.dart
  1. Observe the CLI crash with RangeError: Invalid string length

Additional context
It seems the CLI is buffering the entire stdout/stderr as a string, which overflows when the output is too large (millions of lines in my case).

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.