in src/invoker.ts [93:128]
register() {
process.on('uncaughtException', err => {
console.error('Uncaught exception');
sendCrashResponse({err, res: latestRes, callback: killInstance});
});
process.on('unhandledRejection', err => {
console.error('Unhandled rejection');
sendCrashResponse({err, res: latestRes, callback: killInstance});
});
process.on('exit', (code: number | string) => {
if (typeof code === 'string') {
code = parseInt(code);
}
sendCrashResponse({
err: new Error(`Process exited with code ${code}`),
res: latestRes,
silent: code === 0,
});
});
['SIGINT', 'SIGTERM'].forEach(signal => {
process.on(signal as NodeJS.Signals, () => {
sendCrashResponse({
err: new Error(`Received ${signal}`),
res: latestRes,
silent: true,
callback: () => {
// eslint-disable-next-line no-process-exit
process.exit();
},
});
});
});
}