async-exit-hook
async-exit-hook copied to clipboard
Error thrown in `exitHook` is not handled causing zombie process
The runHook method has no error handling:
if (err) {
// Pass error, calling uncaught exception handlers
return hook(err, stepTowardExit);
}
return hook(stepTowardExit);
If a hook throws, then the exit procedure stops and exit is never actually achieved. (I found this by hitting #9 which threw in an exit routine.)
This could be fixed by wrapping in a try/catch and calling stepTowardsExit on error.