pnpm: Unexpected SIGTERM handling

pnpm version: 5.2.6

Code to reproduce the issue:

// sigterm.js
process.on('SIGTERM', (...args) => {
    console.log(...args);
    setTimeout(process.exit, 5000, 123);
});
setInterval(console.log, 1000, 1);
// package.json
...
"script": {
  "sigterm": "node sigterm.js"
}
...
  1. pnpm run sigterm
  2. in another tty kill -TERM <pid_of_pnpm_run_sigterm>

Expected behavior:

pnpm run sigterm upon receiving SIGTERM should pass the signal to child and wait for it to exit, pass 123 exit code to parent.

Actual behavior:

pnpm run sigterm upon receiving SIGTERM passes signal to child, but does not wait for it to exit, hence child’s exit code is lost (and child is potentially running detached?).

Additional information:

EDIT:

  • change 666 to 123 because it’s capped at 154

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 19 (7 by maintainers)

Most upvoted comments

// package.json
...
"script": {
  "sigterm": "node sigterm.js"
}
...
// sigterm.js
process.once('SIGTERM', () => {
  console.log('SIGTERM');
  
  setTimeout(() => {
    process.exit(0);
  }, 1_000);
});

process.once('SIGINT', () => {
  console.log('SIGINT');

  setTimeout(() => {
    process.exit(0);
  }, 1_000);
});

setInterval(() => {
  console.log('>>>');
}, 1_000);

$ node sigterm.js
>>>
^CSIGINT
>>>

Expected ^

$ pnpm run sigterm

^C ELIFECYCLE  Command failed.

Not expected ^

@zkochan appears to remain an issue

Hope you are safe.

Yes, it was fixed in v7.18.0

I did add it to a priority list but I have too much to do. And it is pretty hard for me to concentrate now, since I am in Ukraine.

I am OK to accept a contribution that makes it work the same way as it works in npm.

The issue is probably in this package: https://github.com/pnpm/npm-lifecycle