Skip to content

npm launcher exits 0 when the native icp binary is killed by a signal #889

Open

Description

@guryanov-a

Summary

The npm package's launcher (npm/icp-cli/bin/icp.js) forwards the child's exit code with child.on('exit', (code) => process.exit(code)). When the native icp binary is killed by a signal (the OOM killer, SIGKILL, a crash), Node calls this handler with code === null and the signal name as the second argument. process.exit(null) exits with status 0, so scripts and CI see a failed command as a success.

Only the npm install (@icp-sdk/icp-cli) is affected: the Homebrew, install-script and cargo installs run the native binary directly.

Reproduction

icp-cli 1.8.0 from npm, macOS arm64, Node v26.10.0:

mkfifo f1
icp identity import repro --storage plaintext --from-pem f1 &   # blocks reading the FIFO
L=$!; sleep 3
kill -KILL "$(pgrep -P "$L")"                                     # kill the native child
wait "$L"; echo "exit status: $?"

Output:

exit status: 0

The identity is not created.

Impact

Any script that checks icp's exit status treats an interrupted command as a success. For example, an interrupted icp build leaves the previous artifact in .icp/cache/artifacts/, and a following install or publish step uses it.

Suggested fix

Re-raise the child's signal, or exit non-zero when there is no code:

child.on('exit', (code, signal) => {
  if (signal) {
    process.kill(process.pid, signal);
    return;
  }
  process.exit(code ?? 1);
});

The npm launcher of ic-wasm has the same handler; it's reported in dfinity/ic-wasm#121.

Written by Claude Opus 5.5 in Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions