Explorar el Código

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

Add unhandledRejection handler when catchErrors is true

GitOrigin-RevId: 7ec1512a8705e6f7cf6480b70427f5bf5d1438b4
Thomas hace 1 año
padre
commit
febc4b6438
Se han modificado 1 ficheros con 8 adiciones y 3 borrados
  1. 8 3
      services/web/app.mjs

+ 8 - 3
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