From febc4b64387662d813f8a1a5b676b6caa5ee31c8 Mon Sep 17 00:00:00 2001 From: Thomas Date: Thu, 17 Oct 2024 13:47:15 +0200 Subject: [PATCH] Merge pull request #21049 from overleaf/tm-web-unhandledrejection Add unhandledRejection handler when catchErrors is true GitOrigin-RevId: 7ec1512a8705e6f7cf6480b70427f5bf5d1438b4 --- services/web/app.mjs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/services/web/app.mjs b/services/web/app.mjs index a6f737eb7e..5b2851b687 100644 --- a/services/web/app.mjs +++ b/services/web/app.mjs @@ -35,9 +35,14 @@ metrics.open_sockets.monitor() if (Settings.catchErrors) { process.removeAllListeners('uncaughtException') - process.on('uncaughtException', error => - logger.error({ err: error }, 'uncaughtException') - ) + process.removeAllListeners('unhandledRejection') + process + .on('uncaughtException', error => + logger.error({ err: error }, 'uncaughtException') + ) + .on('unhandledRejection', (reason, p) => { + logger.error({ err: reason }, 'unhandledRejection at Promise', p) + }) } // Create ./data/dumpFolder if needed