Let me illustrate the problem with the following code:
const cluster = require("cluster");
const exitHook = require("async-exit-hook");
function addHook(delay) {
exitHook(cb => {
console.log("Start " + delay);
setTimeout(() => {
console.log("Finish " + delay);
cb()
}, delay);
});
}
if (cluster.isMaster) {
cluster.fork();
} else {
addHook(0);
addHook(1);
addHook(10);
addHook(100);
}
If I start this script and kill it with ctrl+c, then I get:
$ node exitHook.js
^C
$ Start 0
Start 1
Start 10
Start 100
Finish 0
Finish 1
As you can see, only the very fast exit hooks are executed. This problem only happens in workers. Is this a known issue?
Versions:
- Node: v10.16.3 and v12.8.0
- Async exit hook: 2.0.1
- Operating system: Ubuntu 18.04.1 LTS
Let me illustrate the problem with the following code:
If I start this script and kill it with ctrl+c, then I get:
As you can see, only the very fast exit hooks are executed. This problem only happens in workers. Is this a known issue?
Versions: