Skip to content

Stop hook crashes with 'Transcript path missing' after context compaction #1274

@tsa-logisoft

Description

@tsa-logisoft

Bug

The summarize stop hook throws an unhandled error when the session transcript .jsonl file referenced in a compacted context no longer exists:

Hook error: Error: Transcript path missing or file does not exist: C:\Users\...\<session-id>.jsonl

Root Cause

In scripts/worker-service.cjs, the Cq() function throws instead of returning gracefully when the transcript file is missing or empty:

// Current (throws):
function Cq(t,e,r=!1){
  if(!t||!(0,uv.existsSync)(t))
    throw new Error(`Transcript path missing or file does not exist: ${t}`);
  let n=(0,uv.readFileSync)(t,"utf-8").trim();
  if(!n)
    throw new Error(`Transcript file exists but is empty: ${t}`);
  ...
}

When It Happens

  1. A long session gets context-compacted by Claude Code.
  2. The compacted summary embeds the original session's .jsonl transcript path.
  3. When the next session ends, the stop hook tries to read that old transcript path — but the file no longer exists (it may be in a different project directory, or was cleaned up).
  4. The throw surfaces as a visible hook error to the user.

Suggested Fix

Return the empty result instead of throwing — the same shape the function returns in its happy path:

function Cq(t,e,r=!1){
  if(!t||!(0,uv.existsSync)(t))
    return{userMessage:"",assistantMessage:""};
  let n=(0,uv.readFileSync)(t,"utf-8").trim();
  if(!n)
    return{userMessage:"",assistantMessage:""};
  ...
}

This makes the hook silently skip summarization for missing/empty transcripts rather than surfacing an error to the user.

Environment

  • claude-mem version: 9.1.1
  • Platform: Windows 11
  • Triggered by: worktree-based Claude Code sessions with context compaction

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions