Before submitting
📝 Manual Bug Report
Bug Description
The UserPromptSubmit hook command ends with:
[ "$_HEALTH" = "1" ] && node "$_R/scripts/bun-runner.js" "$_R/scripts/worker-service.cjs" hook claude-code session-init
When _HEALTH=0 (worker unreachable or health check times out), the [ test evaluates false and exits with code 1. Claude Code treats this as a hook failure and shows the following error on every user prompt:
UserPromptSubmit hook error
Failed with non-blocking status code: No stderr output
No stderr output is produced because the shell [ command exits silently with code 1 — leaving the user with no indication of what went wrong.
Steps to Reproduce
- Worker is not running (first session, after crash, or port mismatch after upgrade)
- Claude Code fires
UserPromptSubmit hook
- Health check loop retries 10 times and fails →
_HEALTH=0
[ "0" = "1" ] && node ... → exits code 1
- Claude Code reports hook error on every subsequent prompt
Port mismatch scenario (also triggers this)
~/.claude-mem/settings.json has CLAUDE_MEM_WORKER_PORT: "37777" (set via UI)
- After upgrading to a new version, the old daemon (e.g.
12.3.8) keeps running on 37777
- New version's hook falls back to UID-based port:
37700 + uid % 100
- On this system:
37700 + 502 % 100 = 37702 — mismatch → health check fails → exit code 1
Expected Behavior
Hook exits 0 when worker is unreachable. The health check already makes this a graceful no-op — failing to reach the worker should not be reported as a hook error.
Minimal fix:
# Before
[ "$_HEALTH" = "1" ] && node ... hook claude-code session-init
# After — option A
[ "$_HEALTH" = "1" ] && node ... hook claude-code session-init || true
# After — option B
if [ "$_HEALTH" = "1" ]; then
node ... hook claude-code session-init
fi
Environment
| Field |
Value |
| claude-mem version |
12.3.9 |
| Claude Code version |
2.1.118 |
| OS |
macOS 26.2 (Darwin 25.2.0) |
| Platform |
Apple Silicon (arm64) |
| Shell |
zsh |
| User UID |
502 → fallback port 37702, settings port 37777 |
Logs
Worker itself is healthy once running — the error is purely in hook exit-code handling:
[2026-04-23 11:38:33.067] [INFO ] [SYSTEM] Worker became healthy while waiting on live PID
[2026-04-23 11:38:33.196] [INFO ] [HTTP ] SessionRoutes: handleSessionInitByClaudeId called
[2026-04-23 11:38:33.198] [INFO ] [HOOK ] INIT_COMPLETE | skipped_agent_init=true | reason=context_already_injected
Additional Context
Two related but separable issues:
-
Exit code bug — [ "$_HEALTH" = "1" ] && ... exits 1 when worker is down. Simple || true fix. Affects anyone whose worker is slow to start or temporarily unavailable.
-
Port mismatch after upgrade — Old daemon from a previous version stays alive on the port it was started with. New version's hook calculates a different fallback port. Neither side is "wrong" but they disagree, triggering issue #1.
Workaround applied: Set CLAUDE_MEM_WORKER_PORT in ~/.claude-mem/settings.json to match the UID-based fallback (37700 + uid % 100), then restart the worker.
Before submitting
📝 Manual Bug Report
Bug Description
The
UserPromptSubmithook command ends with:When
_HEALTH=0(worker unreachable or health check times out), the[test evaluates false and exits with code 1. Claude Code treats this as a hook failure and shows the following error on every user prompt:No stderr output is produced because the shell
[command exits silently with code 1 — leaving the user with no indication of what went wrong.Steps to Reproduce
UserPromptSubmithook_HEALTH=0[ "0" = "1" ] && node ...→ exits code 1Port mismatch scenario (also triggers this)
~/.claude-mem/settings.jsonhasCLAUDE_MEM_WORKER_PORT: "37777"(set via UI)12.3.8) keeps running on3777737700 + uid % 10037700 + 502 % 100 = 37702— mismatch → health check fails → exit code 1Expected Behavior
Hook exits
0when worker is unreachable. The health check already makes this a graceful no-op — failing to reach the worker should not be reported as a hook error.Minimal fix:
Environment
37702, settings port37777Logs
Worker itself is healthy once running — the error is purely in hook exit-code handling:
Additional Context
Two related but separable issues:
Exit code bug —
[ "$_HEALTH" = "1" ] && ...exits 1 when worker is down. Simple|| truefix. Affects anyone whose worker is slow to start or temporarily unavailable.Port mismatch after upgrade — Old daemon from a previous version stays alive on the port it was started with. New version's hook calculates a different fallback port. Neither side is "wrong" but they disagree, triggering issue #1.
Workaround applied: Set
CLAUDE_MEM_WORKER_PORTin~/.claude-mem/settings.jsonto match the UID-based fallback (37700 + uid % 100), then restart the worker.