Repository navigation
fix(npm): stop the xurl binary when the wrapper is terminated - #109
Open
EmbryoSpace wants to merge 1 commit into
Open
EmbryoSpace wants to merge 1 commit into
EmbryoSpace wants to merge 1 commit into
Conversation
The npm wrapper ran the binary with execFileSync, which never forwards termination signals. A supervisor or MCP host that stopped the wrapper left the binary running, reparented, with the host's stdio still open. Spawn the binary instead, forward SIGINT, SIGTERM, SIGHUP and SIGQUIT, and exit with the binary's exit code or signal. Fixes xdevplatform#93
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.
Fixes #93.
Problem
npm/cli.jsruns the binary withexecFileSync. That call never forwards termination signals to the child, so when a supervisor stops the Node wrapper, the binary keeps running, gets reparented, and still holds the host's stdin and stdout. Forxurl mcpthis means an MCP host that restarts the command collects a stray bridge process each time.Fix
spawn(stdio: "inherit", same as before).Testing
On Linux (Docker,
node:18-alpineandnode:20-bookworm-slim), with a stand-in binary that records its pid and waits, I sent each signal to the wrapper and checked the binary 0.5 s later:Also checked, before and after:
exit3 a "b c"exits 3 with the same arguments).xurl mcp.One limit: SIGKILL can't be caught, so a wrapper killed with SIGKILL still can't stop its child. Hosts that want a hard guarantee can invoke the binary directly. That's the other option in the issue, and I left it alone because it changes how the package is installed.