claude-code - 💡(How to fix) Fix Occasional crashes (cli.js:5015) in v2.1.116 during development tasks [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52449Fetched 2026-04-24 06:06:57
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

Error Message

Observe that, occasionally, the CLI may crash with the error in cli.js:5015.

Error Messages/Logs

Root Cause

Observe that the CLI crashes nearly every 2-3 turns, often accompanied by ConnectionRefused retries that never succeed because the local process state is corrupted.

Code Example

"assistant"&&!h07(k))break;if(k.type==="assistant"){if(k.message.id===G.message.id){f[Z]=mJ1(k,G),W=!0;break}continue}}if(!W)f.push(G);continue}case"attachment":{let
     X=Wf6(J.attachment),L=S3("tengu_chair_sermon")?X.map(RJ1):X,P=fx(f);if(P?.type==="user"){f[f.length-1]=L.reduce((G,W)=>uJ1(G,W),P);continue}f.push(...L);continue}}}let
     z=S3("tengu_toolref_defer_j8m")?CJ1(f):f,Y=P4$(z),O=AX1(Y),M=L4$(O),w=fX1(M),D=S3("tengu_chair_sermon")?E07(pJ1(w)):w;return bJ1(D)}function uJ1(H,$){let
     q=ke$(H.message.content),K=ke$($.message.content);return{...H,message:{...H.message,content:S07(FJ1(q,K))}}}function mJ1(H,$){let
     q=[...H.message.content,...$.message.content],K=q.filter((A)=>A.type!=="text"||A.text.length===0||A.text.trim()!==""),_=K.some((A)=>A.type!=="thinking"&&A.type!=="redacted_th
     inking");return{...H,message:{...H.message,content:_?K:q}}}function h07(H){if(H.type!=="user")return!1;let $=H.message.content;if(typeof $==="string")return!1;return
     $.some((q)=>q.type==="tool_result")}function Te$(H,$){let
     q=ke$(H.message.content),K=ke$($.message.content);return{...H,uuid:H.isMeta?$.uuid:H.uuid,message:{...H.message,content:S07(BJ1(q,K))}}}function pJ1(H){let $=!1;for(let
     K=1;K<H.length;K++)if(H[K].type==="user"&&H[K-1].type==="user"){$=!0;break}if(!$)return H;let q=[];for(let K of H){let
     _=q.at(-1);if(K.type==="user"&&_?.type==="user")q[q.length-1]=Te$(_,K);else q.push(K)}return q}function S07(H){let $=[],q=[];for(let K of
     H)if(K.type==="tool_result")$.push(K);else q.push(K);return[...$,...q]}function ke$(H){if(typeof H==="string")return[{type:"text",text:H}];return H}function BJ1(H,$){let
     q=H.at(-1),K=$[0];if(q?.type==="text"&&K?.type==="text")return[...H.slice(0,-1),{...q,text:q.text+`
 5018: `},...$];return[...H,...$]}function M36(H,$){if($.length===0)return H;let q=H.content;if(Array.isArray(q)&&q.some(xg))return
      null;if(H.is_error){if($=$.filter((f)=>f.type==="text"),$.length===0)return H}if($.every((f)=>f.type==="text")&&(q===void 0||typeof q==="string")){let
      f=[(q??"").trim(),...$.map((z)=>z.text.trim())].filter(Boolean).join(`

 - H5$ (/$bunfs/root/src/entrypoints/cli.js:5015:1278)
 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:6278:14177)
 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:6278:14112)
 - y2 (/$bunfs/root/src/entrypoints/cli.js:477:30122)
 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:467:9116)
 - BE1 (/$bunfs/root/src/entrypoints/cli.js:6278:14097)
 - wD (/$bunfs/root/src/entrypoints/cli.js:477:21022)
 - CA (/$bunfs/root/src/entrypoints/cli.js:477:39569)
 - kN (/$bunfs/root/src/entrypoints/cli.js:477:50270)
 - sBH (/$bunfs/root/src/entrypoints/cli.js:477:86946)
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code v2.1.116 occasionally crashes with a JavaScript stack trace. These crashes do not happen every time but have been observed during file updates or when the CLI is processing data.

I have noted that these occasional crashes seem to occur more often when multiple Claude Code instances are running simultaneously in different terminal windows.

What Should Happen?

Open several terminal windows and start claude in each.

Perform tasks such as file updates or processing code.

Observe that, occasionally, the CLI may crash with the error in cli.js:5015.

Error Messages/Logs

"assistant"&&!h07(k))break;if(k.type==="assistant"){if(k.message.id===G.message.id){f[Z]=mJ1(k,G),W=!0;break}continue}}if(!W)f.push(G);continue}case"attachment":{let
     X=Wf6(J.attachment),L=S3("tengu_chair_sermon")?X.map(RJ1):X,P=fx(f);if(P?.type==="user"){f[f.length-1]=L.reduce((G,W)=>uJ1(G,W),P);continue}f.push(...L);continue}}}let
     z=S3("tengu_toolref_defer_j8m")?CJ1(f):f,Y=P4$(z),O=AX1(Y),M=L4$(O),w=fX1(M),D=S3("tengu_chair_sermon")?E07(pJ1(w)):w;return bJ1(D)}function uJ1(H,$){let
     q=ke$(H.message.content),K=ke$($.message.content);return{...H,message:{...H.message,content:S07(FJ1(q,K))}}}function mJ1(H,$){let
     q=[...H.message.content,...$.message.content],K=q.filter((A)=>A.type!=="text"||A.text.length===0||A.text.trim()!==""),_=K.some((A)=>A.type!=="thinking"&&A.type!=="redacted_th
     inking");return{...H,message:{...H.message,content:_?K:q}}}function h07(H){if(H.type!=="user")return!1;let $=H.message.content;if(typeof $==="string")return!1;return
     $.some((q)=>q.type==="tool_result")}function Te$(H,$){let
     q=ke$(H.message.content),K=ke$($.message.content);return{...H,uuid:H.isMeta?$.uuid:H.uuid,message:{...H.message,content:S07(BJ1(q,K))}}}function pJ1(H){let $=!1;for(let
     K=1;K<H.length;K++)if(H[K].type==="user"&&H[K-1].type==="user"){$=!0;break}if(!$)return H;let q=[];for(let K of H){let
     _=q.at(-1);if(K.type==="user"&&_?.type==="user")q[q.length-1]=Te$(_,K);else q.push(K)}return q}function S07(H){let $=[],q=[];for(let K of
     H)if(K.type==="tool_result")$.push(K);else q.push(K);return[...$,...q]}function ke$(H){if(typeof H==="string")return[{type:"text",text:H}];return H}function BJ1(H,$){let
     q=H.at(-1),K=$[0];if(q?.type==="text"&&K?.type==="text")return[...H.slice(0,-1),{...q,text:q.text+`
 5018: `},...$];return[...H,...$]}function M36(H,$){if($.length===0)return H;let q=H.content;if(Array.isArray(q)&&q.some(xg))return
      null;if(H.is_error){if($=$.filter((f)=>f.type==="text"),$.length===0)return H}if($.every((f)=>f.type==="text")&&(q===void 0||typeof q==="string")){let
      f=[(q??"").trim(),...$.map((z)=>z.text.trim())].filter(Boolean).join(`

 - H5$ (/$bunfs/root/src/entrypoints/cli.js:5015:1278)
 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:6278:14177)
 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:6278:14112)
 - y2 (/$bunfs/root/src/entrypoints/cli.js:477:30122)
 - <anonymous> (/$bunfs/root/src/entrypoints/cli.js:467:9116)
 - BE1 (/$bunfs/root/src/entrypoints/cli.js:6278:14097)
 - wD (/$bunfs/root/src/entrypoints/cli.js:477:21022)
 - CA (/$bunfs/root/src/entrypoints/cli.js:477:39569)
 - kN (/$bunfs/root/src/entrypoints/cli.js:477:50270)
 - sBH (/$bunfs/root/src/entrypoints/cli.js:477:86946)

Steps to Reproduce

Initiate a complex task (e.g., data processing or large-scale refactoring).

Allow Claude to perform several consecutive file edits.

Observe that the CLI crashes nearly every 2-3 turns, often accompanied by ConnectionRefused retries that never succeed because the local process state is corrupted.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.116 (Claude Code)

Platform

Other

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Cursor

Additional Information

No response

extent analysis

TL;DR

The issue can be mitigated by running a single instance of Claude Code at a time, as concurrent instances may cause crashes.

Guidance

  • To reduce crashes, ensure that only one instance of Claude Code is running at any given time.
  • When performing complex tasks, consider breaking them down into smaller, sequential operations to minimize the load on the system.
  • Monitor system resources (e.g., memory, CPU usage) while running Claude Code to identify potential bottlenecks.
  • If crashes persist, try updating to a newer version of Claude Code, if available, as the issue may have been addressed in a later release.

Example

No specific code changes are recommended at this time, as the issue appears to be related to concurrent instance execution.

Notes

The root cause of the crashes is unclear, but running multiple instances of Claude Code simultaneously seems to increase the likelihood of errors. Further investigation into the specific error messages and system conditions may be necessary to identify a permanent fix.

Recommendation

Apply workaround: Run a single instance of Claude Code at a time to minimize crashes, as this approach has been observed to reduce the frequency of errors.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Occasional crashes (cli.js:5015) in v2.1.116 during development tasks [1 comments, 2 participants]