catch all uncaught errors in winston

This commit is contained in:
Milo Schwartz 2024-09-28 14:07:25 -04:00
parent 9c40d8a5c7
commit ac6a6d7616
No known key found for this signature in database

View file

@ -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;