Skip to content

SessionStart hook fails silently with 'No stderr output' when worker health check times out #1794

Description

@cags84

Summary

The SessionStart hook in hooks/hooks.json (worker health check block) exits with code 1 without writing to stderr when the bun worker on localhost:37777 doesn't respond to /health within the 8-second retry window. Claude Code surfaces this as a confusing non-blocking error:

SessionStart:startup hook error
  ⎿ Failed with non-blocking status code: No stderr output

Repro

  1. Ensure no claude-mem worker is running (lsof -iTCP:37777 -sTCP:LISTEN returns empty).
  2. Start a new Claude Code session.
  3. If the worker takes more than ~8s to become healthy, the hook fails silently.

Also reproducible after system sleep/reboot when the previous worker process died and the new one is slow to bind the port.

Root Cause

In hooks/hooks.json, the second and third SessionStart hooks end with:

for i in 1 2 3 4 5 6 7 8; do curl -sf http://localhost:37777/health >/dev/null 2>&1 && break; sleep 1; done; curl -sf http://localhost:37777/health >/dev/null 2>&1 || exit 1

The exit 1 bails silently — no diagnostic message, no log path, nothing. The user sees only the generic Claude Code message with no way to know which plugin or hook failed.

Suggested Fixes

  1. Emit a clear stderr message before exiting, e.g.:
    || { echo "claude-mem: worker on :37777 did not become healthy within 8s" >&2; exit 1; }
  2. Consider increasing the retry budget, or using exponential backoff, for cold-start scenarios.
  3. Optionally log the worker startup output to a file (~/.claude-mem/worker.log) so users can debug without reproducing.

Environment

  • macOS Darwin 25.4.0
  • Claude Code (CLI)
  • claude-mem plugin version 12.1.0
  • Worker eventually becomes healthy; this is purely a startup race.

Workaround

Ignore the message (it's non-blocking) — subsequent sessions work fine once the worker is up.


Reported by @cags84

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