Crash: null is not an object (evaluating 'z.isMemoryWrite') in message collapsing

Resolved 💬 2 comments Opened Apr 17, 2026 by digijoebz Closed May 8, 2026

Summary

Claude Code crashed ungracefully with ERROR null is not an object (evaluating 'z.isMemoryWrite'). The crash interrupted an active long-running session that had been running cleanly for hours.

Version

  • claude CLI: 2.1.112 (Claude Code)
  • Linux x86_64 (Ubuntu 6.8.0-110-generic)
  • Shell: bash

Error trace (top frames)

jJ7 (/$bunfs/root/src/entrypoints/cli.js:4779:2464)
<anonymous> (/$bunfs/root/src/entrypoints/cli.js:6260:14646)
TT (/$bunfs/root/src/entrypoints/cli.js:477:30111)
...

Root cause (from the minified source)

In A51(H, $):

function A51(H,$){
  if(H.type==="assistant"){
    let q=H.message.content[0], K=cK$(q,$);
    if(K && q?.type==="tool_use") return {name:q.name, input:q.input, ...K}
  }
  if(H.type==="grouped_tool_use"){
    let q=H.messages[0]?.message.content[0];
    let K=cK$(q ? {type:"tool_use", name:H.toolName, input:q.input} : void 0, $);
    if(K && q?.type==="tool_use") return {name:H.toolName, input:q.input, ...K}
  }
  return null   // ← can return null
}

In jJ7, the caller:

let z = A51(f, $);
if (z.isMemoryWrite) { ... }  // ← crashes here when z === null

The caller is inside the branch where O51(f, $) is true (collapsible tool use) but A51 can still return null — e.g. if the tool classification (cK$) returns falsy for the wrapped content, or if q?.type !== "tool_use".

Context of the crash

I was in a long session working on a knowledge-base pipeline. Many tool uses had already happened. The crash hit while I was running a batch of Bash/Edit tool calls via an ongoing conversation. The session had been running for hours with high message density. Nothing unusual about the last tool call — just a normal Bash invocation. The crash was unrecoverable: the terminal dumped the full minified stack and exited.

Expected behavior

Null check on z before accessing z.isMemoryWrite, or make A51 always return a shape-complete object (with isMemoryWrite: false default) instead of null.

Suggested fix

In jJ7, where A51's result is consumed:

let z = A51(f, $);
if (!z) continue;   // or handle the null branch
if (z.isMemoryWrite) { ... }

Or equivalently, make A51 return a default object instead of null:

return { name: "", input: null, isMemoryWrite: false, isAbsorbedSilently: false, ... };

Impact

  • Long sessions are at risk of dying mid-work due to one unclassifiable tool_use message.
  • No graceful recovery — the whole CLI exits. Users lose session state, in-flight background tasks may orphan (in my case an overnight pipeline run).

View original on GitHub ↗

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