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:
@@ -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 };
|
||||
Reference in New Issue
Block a user