From ac6a6d7616be131a990f5bfbe3309b7c09374eaa Mon Sep 17 00:00:00 2001 From: Milo Schwartz Date: Sat, 28 Sep 2024 14:07:25 -0400 Subject: [PATCH] catch all uncaught errors in winston --- server/logger.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/logger.ts b/server/logger.ts index 9969530b..793e902a 100644 --- a/server/logger.ts +++ b/server/logger.ts @@ -72,4 +72,13 @@ const logger = winston.createLogger({ transports, }); +process.on("uncaughtException", (error) => { + logger.error("Uncaught Exception:", { error, stack: error.stack }); + process.exit(1); +}); + +process.on("unhandledRejection", (reason, _) => { + logger.error("Unhandled Rejection:", { reason }); +}); + export default logger;