Crash on conversation resume: H.indexOf is not a function in isResultTruncated
Status Fixed / completed
Maintainer reply ✓ Yes — ashwin-ant
Workaround ✓ Mentioned in thread ↓
Activity 3 comments · opened Apr 3, 2026 · closed Apr 18, 2026
💡 Likely answer: A maintainer (ashwin-ant, collaborator)
responded on this thread — see the highlighted reply below.
Bug
Resuming a conversation crashes with:
ERROR H.indexOf is not a function. (In 'H.indexOf(`
`,_)', 'H.indexOf' is undefined)
Stack trace
Hb (/$bunfs/root/src/entrypoints/cli.js:1518:65)
isResultTruncated (/$bunfs/root/src/entrypoints/cli.js:1540:4784)
<anonymous> (/$bunfs/root/src/entrypoints/cli.js:5959:15701)
<anonymous> (/$bunfs/root/src/entrypoints/cli.js:5959:7779)
map (native:1:11)
QW7 (/$bunfs/root/src/entrypoints/cli.js:5959:7735)
fO (/$bunfs/root/src/entrypoints/cli.js:480:20983)
qA (/$bunfs/root/src/entrypoints/cli.js:480:39521)
Gk (/$bunfs/root/src/entrypoints/cli.js:480:50210)
EDH (/$bunfs/root/src/entrypoints/cli.js:480:86865)
Analysis
isResultTruncated calls .indexOf("\n") on a value (H) that is undefined instead of a string. This likely happens when a tool result in the persisted conversation has a null/undefined content field that isn't guarded before the string method call.
Reproduction
- Have a conversation with tool calls
- Exit
- Resume with
claude --resume - Crash occurs during conversation restoration
Environment
- Platform: macOS (Darwin 24.6.0)
- Runtime: Bun
3 Comments
Update: Root cause narrowed down
The crash is not caused by null content fields in messages, system messages, or file-history-snapshots. I patched all of those and the crash persisted.
The crash is specifically triggered by tool_use/tool_result block structures during conversation rendering on resume.
What I tried (didn't fix the crash):
textfields intool_referenceitems insidetool_resultarrays → still crashednullcontent → still crashedbackupFileNamevalues infile-history-snapshotentries → still crashedtool_resultcontent to strings while keeping block type astool_result→ still crashedWhat fixed it:
Converting all
tool_useandtool_resultblocks totextblocks (e.g.,[Used tool: Read with input: {...}]/[Tool result: ...]) and droppingfile-history-snapshotentries. This preserves conversation context while avoiding the renderer crash.Conclusion:
The
isResultTruncatedfunction (or something in its call chain via the.map()inQW7) crashes when processing tool_use/tool_result block types during re-rendering, not due to null values but likely due to the block structure itself. The conversation had MCP tool results (Datadog, Glean, Linear) which may have non-standard content shapes the renderer doesn't handle.Workaround for others:
This was fixed in v2.1.97 — Resuming a conversation with array-shaped MCP tool results no longer crashes with 'H.indexOf is not a function'. If you're still seeing this in the latest version, please comment with your version and repro and we'll reopen.
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.