Skip to content

fix(npm): forward SIGINT/SIGTERM/SIGHUP from the npm shim to the Go binary - #504

Open
pcbeingused333 wants to merge 1 commit into
hookdeck:mainfrom
pcbeingused333:fix/npm-shim-forward-signals
Open

pcbeingused333 wants to merge 1 commit into
hookdeck:mainfrom
pcbeingused333:fix/npm-shim-forward-signals

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #429

Root cause: bin/hookdeck.js ran the Go binary with execFileSync, which blocks the Node event loop. A signal delivered to the Node process (e.g. kill <pid> from a supervisor, or a terminal hangup) was therefore never forwarded, and the CLI child was left running/orphaned instead of shutting down cleanly.

Fix: use spawn with stdio: 'inherit', forward SIGINT/SIGTERM/SIGHUP to the child, propagate the child's exit code, and if the child dies from a signal re-raise it on the shim so the parent shell sees the same status. A spawn error prints a message and exits 1 (as before).

Test: test-scripts/npm-shim.test.js (node --test test-scripts/, no dependencies) copies the shim next to a fake binaries/<platform>-<arch>/hookdeck shell script and checks exit-code/argument propagation and that each of the three signals reaches the child. On main the three signal tests hang (signal never delivered); with the fix all 4 pass.


Disclosure: this change was prepared with AI assistance (Claude Code) and submitted by a human contributor; the submitter is responsible for the contents.

…inary

The shim used execFileSync, which blocks the event loop, so signals sent to
the Node process never reached the CLI (hookdeck listen did not shut down
cleanly under systemd/docker stop). Use spawn, forward the three signals,
propagate the exit code, and re-raise a fatal signal from the child.

Fixes hookdeck#429

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm shim does not forward signals, so listen cannot shut down gracefully

1 participant