From ed444dfec7158b64de07462002aca48bbc34f33f Mon Sep 17 00:00:00 2001 From: nimesh-kumar-sh Date: Fri, 27 Mar 2026 12:52:02 -0700 Subject: [PATCH] fix: SessionStart hooks fail on cold start due to worker race condition The worker-start hook's `start` subcommand forks a daemon then SIGKILLs its own process group, killing bun-runner.js before it can report exit 0. Since all SessionStart hooks run in parallel, the context hook also fails because the worker isn't listening yet. Fix: - worker-start: continue after the SIGKILL via `;`, poll the worker health endpoint until ready, then output valid JSON (exit 0) - context: wait for worker health before attempting to fetch context Fixes #1505 --- plugin/hooks/hooks.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/hooks/hooks.json b/plugin/hooks/hooks.json index 01a6b719..381d3599 100644 --- a/plugin/hooks/hooks.json +++ b/plugin/hooks/hooks.json @@ -24,12 +24,12 @@ }, { "type": "command", - "command": "_R=\"${CLAUDE_PLUGIN_ROOT}\"; [ -z \"$_R\" ] && _R=\"$HOME/.claude/plugins/marketplaces/thedotmack/plugin\"; node \"$_R/scripts/bun-runner.js\" \"$_R/scripts/worker-service.cjs\" start", + "command": "_R=\"${CLAUDE_PLUGIN_ROOT}\"; [ -z \"$_R\" ] && _R=\"$HOME/.claude/plugins/marketplaces/thedotmack/plugin\"; node \"$_R/scripts/bun-runner.js\" \"$_R/scripts/worker-service.cjs\" start; 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; echo '{\"continue\":true,\"suppressOutput\":true}'", "timeout": 60 }, { "type": "command", - "command": "_R=\"${CLAUDE_PLUGIN_ROOT}\"; [ -z \"$_R\" ] && _R=\"$HOME/.claude/plugins/marketplaces/thedotmack/plugin\"; node \"$_R/scripts/bun-runner.js\" \"$_R/scripts/worker-service.cjs\" hook claude-code context", + "command": "_R=\"${CLAUDE_PLUGIN_ROOT}\"; [ -z \"$_R\" ] && _R=\"$HOME/.claude/plugins/marketplaces/thedotmack/plugin\"; 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; node \"$_R/scripts/bun-runner.js\" \"$_R/scripts/worker-service.cjs\" hook claude-code context", "timeout": 60 } ]