Crash on session resume: undefined is not an object (evaluating 'H.startsWith') in Edit result renderer

Resolved 💬 7 comments Opened Mar 29, 2026 by tiffsequence Closed Apr 10, 2026

Bug Description

When resuming a previously closed conversation session (selecting it from the session list and pressing Enter), Claude Code crashes with:

ERROR  undefined is not an object (evaluating 'H.startsWith')

The session was working normally before being closed. The crash occurs immediately on resume, before any interaction.

Stack Trace

DR7 (/$bunfs/root/src/entrypoints/cli.js:1772:487)
Ce7 (/$bunfs/root/src/entrypoints/cli.js:2929:18047)
_w (/$bunfs/root/src/entrypoints/cli.js:453:20997)
$O (/$bunfs/root/src/entrypoints/cli.js:453:39538)
Ks (/$bunfs/root/src/entrypoints/cli.js:453:50229)
sEH (/$bunfs/root/src/entrypoints/cli.js:453:86903)
M0 (/$bunfs/root/src/entrypoints/cli.js:453:85865)
aEH (/$bunfs/root/src/entrypoints/cli.js:453:85687)
WDH (/$bunfs/root/src/entrypoints/cli.js:453:82433)
FH (/$bunfs/root/src/entrypoints/cli.js:453:6488)

Root Cause Analysis

The crash is in the DR7 function which renders Edit tool structured results:

function DR7({filePath:H, structuredPatch:_, originalFile:q}, $, {style:K, verbose:O}) {
  let T = H.startsWith(PT()); // <-- crashes here, H is undefined
  ...
}

Unlike YR7 (which guards with if(!H) return null) and vV_ (which uses optional chaining H.file_path?.startsWith), DR7 does not null-check filePath before calling .startsWith().

Thorough data analysis of the session file (1633 lines, 152 Edit/Write tool calls, plus subagent files including compact) found zero malformed entries — all file_path values are valid strings, all tool_use/tool_result pairs are matched, no orphaned entries, no structural anomalies. This suggests the issue is in how the renderer reconstructs/receives props during session reload, not in the persisted data.

Suggested Fix

Add a null guard in DR7, consistent with the pattern used in YR7:

function DR7({filePath:H, structuredPatch:_, originalFile:q}, $, {style:K, verbose:O}) {
  if (!H) return null; // Add this guard
  let T = H.startsWith(PT());
  ...
}

Environment

  • Claude Code version: 2.1.87
  • OS: macOS Darwin 25.2.0 (arm64)
  • Runtime: Bun (per /$bunfs/root/ path prefix)

Session Characteristics

The affected session is a large, long-running conversation with:

  • 1633 JSONL entries in main session file (5.4MB)
  • 152 Edit/Write tool_use entries (all with valid file_path strings)
  • 12+ subagent files including a 1.9MB compact subagent
  • Multiple cross-repository Edit operations (editing files in ~8 different repo directories)
  • Context compaction was triggered during the session

Steps to Reproduce

  1. Have a long conversation session with many Edit/Write tool calls across multiple repositories
  2. Close the session normally
  3. Restart Claude Code and select the session to resume
  4. Crash occurs immediately during conversation render

Workaround

No known workaround yet — the session data appears valid but the renderer crashes during reload.

View original on GitHub ↗

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