Skip to content

[Bug] npm launcher reports success when the native process dies by signal #175

Description

@morluto

Description

The npm launcher turns a native child process that terminates by signal into a successful wrapper exit.

npm/bin/gitcontribute.cjs installs handlers for SIGINT, SIGTERM, and SIGHUP. When the child exits because of a signal, its exit callback sends the same signal to the launcher:

if (signal) {
  process.kill(process.pid, signal);
  return;
}

The launcher's own installed handler catches that signal instead of allowing the default termination behavior. Once the child and event loop are gone, Node exits normally with status 0.

This was reproduced on Linux with a fixture native binary containing:

#!/bin/sh
kill -TERM $$

Running that fixture through node npm/bin/gitcontribute.cjs produced wrapper exit status 0. A caller, script, or agent therefore sees success even though GitContribute was terminated.

The existing launcher test covers numeric child exit status but not signal termination.

Expected behavior

The npm wrapper should preserve native process failure semantics when the child terminates by signal. On platforms that support the signal, the wrapper should terminate from the same signal; otherwise it should return an unambiguously non-zero status.

Before re-raising a child signal, the launcher can remove or disable its forwarding handler so it does not intercept its own signal. The implementation should also account for the platform-specific signal support exposed by Node.

Add a regression test with a fixture child that terminates itself by SIGTERM and assert that the wrapper cannot report status 0.

Affected code

  • npm/bin/gitcontribute.cjs: signal forwarding and child exit handling
  • npm/launcher.test.mjs: launcher process-semantics coverage

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions