I've come across a problem on one of my Nodejs apps running with npm start
(which just does node app.js
).
My app contains a sigint handler as follows:
process.on('SIGINT', () => {
db.disconnect().then({
process.exit(0);
}).catch(e => process.exit(1));
});
With corresponding logs. After some testing on other files, I've noticed that Ctrl-C when on an npm
process triggers SIGINT twice if the first one takes too long to exit. (try adding a timeout on a sample app).
For now I've added a counter to check if the call is performed more than once, but I'm not sure that's "the way to go" concerning this issue. I'm guessing that a SIGINT on an npm process is expected to quit in a certain timeframe, which is why npm passes it on one more time (always only twice).
Has anyone come across this problem and found a viable solution?
Thanks!
npm start
and close with CTRL+C, and also withsystemctl start/stop service
the termination signal is sent twice, while after starting withnode index.js
it is sent only once. Node 8.15.0 and Npm 6.4.1 on all setups. – CausehandleSIGINT
tofalse
when launching the browser:await puppeteer.launch({ handleSIGINT: false, ...})
cause puppeteer calls process.exit() on SIGINT. – Mediatorial