Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All user-visible bugs and enhancements should be recorded here.

## Unreleased

### Fixed

- Stopping the npm `xurl` command now stops the xurl binary too. The npm wrapper started the binary without passing on termination signals, so when a process supervisor or MCP host stopped it (for example to restart `xurl mcp`), the binary kept running detached with the host's input and output still open. The wrapper now forwards SIGINT, SIGTERM, SIGHUP and SIGQUIT and exits with the binary's exit code or signal.

## v1.3.4 - 2026-09-29

### Fixed
Expand Down
36 changes: 31 additions & 5 deletions npm/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

const { execFileSync } = require("child_process");
const { spawn } = require("child_process");
const path = require("path");
const fs = require("fs");

Expand All @@ -11,8 +11,34 @@ if (!fs.existsSync(binary)) {
process.exit(1);
}

try {
const result = execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
} catch (e) {
process.exit(e.status || 1);
// Run the binary as a child we can signal. A supervisor that stops this wrapper
// (an MCP host restarting `xurl mcp`, a process manager, Ctrl+C) must stop the
// binary too, or it keeps running detached with the host's stdio pipes open.
const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });

const forwarded = ["SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT"];
const relay = (signal) => {
if (child.exitCode === null && child.signalCode === null) child.kill(signal);
};
for (const signal of forwarded) {
try {
process.on(signal, relay);
} catch (e) {
// Not every signal can be listened for on every platform.
}
}

child.on("error", (e) => {
console.error(`xurl: could not start ${binary}: ${e.message}`);
process.exit(1);
});

child.on("exit", (code, signal) => {
if (signal) {
// End the same way the binary did, so callers see the same exit status.
for (const s of forwarded) process.removeListener(s, relay);
process.kill(process.pid, signal);
return;
}
process.exit(code === null ? 1 : code);
});