Merge pull request #21049 from overleaf/tm-web-unhandledrejection

Add unhandledRejection handler when catchErrors is true

GitOrigin-RevId: 7ec1512a8705e6f7cf6480b70427f5bf5d1438b4
This commit is contained in:
Thomas 2024-10-17 13:47:15 +02:00 committed by Copybot
parent e782ba2fee
commit febc4b6438

View file

@ -35,9 +35,14 @@ metrics.open_sockets.monitor()
if (Settings.catchErrors) { if (Settings.catchErrors) {
process.removeAllListeners('uncaughtException') process.removeAllListeners('uncaughtException')
process.on('uncaughtException', error => process.removeAllListeners('unhandledRejection')
process
.on('uncaughtException', error =>
logger.error({ err: error }, 'uncaughtException') logger.error({ err: error }, 'uncaughtException')
) )
.on('unhandledRejection', (reason, p) => {
logger.error({ err: reason }, 'unhandledRejection at Promise', p)
})
} }
// Create ./data/dumpFolder if needed // Create ./data/dumpFolder if needed