Repository navigation
fix: preserve child termination signals in the npm wrapper - #85
Merged
alexshapalov merged 1 commit intoSep 27, 2026
Merged
Conversation
The wrapper intercepted its own final re-raised signal with the forwarding listener, allowing a signaled child to become a successful wrapper exit. Track forwarding handlers and remove them only before the final self-signal. Keep forwarding while the binary runs and preserve numeric graceful exits. Replace the unbounded fixed-delay signal test with ready-file handshakes, bounded waits and cleanup of both owned processes. Verification: the real wrapper returns zero after self-SIGTERM on base 282ffe8, while the corrected suite passes all 11 tests. Controls cover SIGINT, SIGTERM, SIGHUP, graceful exit 143, normal exit 0, nonzero exit 2, spawn failure 3, missing package 64 and argument forwarding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Closes #84.
Remove the registered forwarding handlers immediately before reproducing a child's terminating signal on the wrapper process. Otherwise the wrapper catches its own final signal and can report successful exit zero.
Forwarding remains active while the binary runs, and graceful numeric exits remain intact. The tests use real child processes and the actual npm layout, bounded readiness/exit waits and cleanup of owned processes. They retain coverage for a child that handles TERM and exits 143.
Verification
Verified commit:
32dd69c0b3bdb3974c7a857bdeaefb2ea3a3cc77.282ffe8fdd7acdd7b6e1dbd8cf04c155401d3a92: child self-SIGTERM yields wrapper exit 0 instead of SIGTERM.node --test npm/test/wrapper.test.mjs: all 11 tests pass on macOS/arm64 (Node v25.2.1).bash scripts/gate.sh: passes committed HEAD, including pinned lint, unit tests and all six Go release-target builds.go test -race ./...: passes.bash npm/test/pack-smoke.sh npm bun: passes actual local tarball installations with lifecycle scripts disabled and executes the real binary via Node and Bun runtimes.git diff --check: clean.Scope and risk
The signal-process fixtures are POSIX-specific; this does not claim Windows runtime signal validation. Numeric exit codes, arguments and missing-package diagnostics remain unchanged. No dependencies, collector SQL, database migrations or JSON changes. Revert the commit to restore the prior handler lifecycle.
Checklist
scripts/gate.shpasses on committed HEAD; full race suite passes.