From c7e0415786492ae3a74f70be0ecfe09de98084c4 Mon Sep 17 00:00:00 2001 From: Luca Armaroli Date: Thu, 24 Sep 2020 02:30:49 +0200 Subject: [PATCH] process.exit on uncaught exceptions --- src/Events.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Events.ts b/src/Events.ts index 6585cd7..90873c2 100644 --- a/src/Events.ts +++ b/src/Events.ts @@ -24,6 +24,11 @@ export function setProcessEvents(): void { process.exit(777); }); + process.on('uncaughtException', (err: Error) => { + logger.error(err); + process.exit(ERROR_CODE.UNHANDLED_ERROR); + }); + process.on('unhandledRejection', (reason: {} | null | undefined) => { if (reason instanceof Error) { logger.error({ message: (reason as Error) });