Prevent infinite loop when exiting

pull/5536/head
Chocobozzz 2022-10-13 09:06:07 +02:00 committed by John McLear
parent 0dea4cb1c8
commit f456606015
1 changed files with 8 additions and 1 deletions

View File

@ -107,7 +107,14 @@ exports.start = async () => {
process.on('uncaughtException', (err) => {
logger.debug(`uncaught exception: ${err.stack || err}`);
exports.exit(err);
// eslint-disable-next-line promise/no-promise-in-callback
exports.exit(err)
.catch((err) => {
logger.error('Error in process exit', err);
// eslint-disable-next-line n/no-process-exit
process.exit(1);
});
});
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.