Stop crashing the server on unhandled promise rejections

A single missed .catch() anywhere in the notification code (email/WhatsApp
sending) previously took down the whole process via process.exit(1). Log
the error instead and keep running.
This commit is contained in:
2026-08-26 09:03:15 +02:00
parent d6da2c8227
commit e63fb2cc27
2 changed files with 6 additions and 4 deletions
+5 -4
View File
@@ -1265,11 +1265,12 @@ app.listen(PORT, () => {
}
});
// Handle unhandled promise rejections
// Log unhandled promise rejections without killing the server, since a single
// missed .catch() on fire-and-forget notification code (email/WhatsApp sends)
// would otherwise take the whole app down.
process.on('unhandledRejection', (err) => {
console.log('UNHANDLED REJECTION! Shutting down...');
console.log(err.name, err.message);
process.exit(1);
console.error('UNHANDLED REJECTION!', err?.name, err?.message);
console.error(err?.stack || err);
});
module.exports = { app, prisma };