mirror of
https://github.com/thedotmack/claude-mem
synced 2026-04-25 17:15:04 +02:00
The three SessionStart hooks poll http://localhost:37777/health with an 8-second retry budget and then exit 1 silently (via `curl -sf || exit 1`) when the worker has not stabilized in time. Claude Code surfaces this as two `SessionStart:startup hook error - Failed with non-blocking status code: No stderr output` messages on every first session of the day. This happens because of a race between the MCP server auto-starting the worker and the hook's own `worker-service.cjs start` path, which on Linux respects a live PID file written by an earlier session and waits for the existing worker to become healthy. 8s is not always enough. Mitigate in the hook layer without touching worker-service.cjs: - bump the inner retry loop from 8 to 20 attempts (up to ~20s) - replace `|| exit 1` with `|| true` so the hook emits its continue JSON regardless (Claude Code no longer logs a phantom error) - guard the context-injection hook with a health check - only run `worker-service.cjs hook claude-code context` if the worker is actually responding, otherwise skip silently Trade-off: on cold starts where the worker takes longer than ~20s to come up, the recent-context preamble is skipped for that first session instead of surfacing an error. Subsequent sessions in the same day work normally because the worker is already healthy. Refs #1447