From 7a32e5e6ffeadd118f55e94359429563d44ada3e Mon Sep 17 00:00:00 2001 From: LouisLam Date: Tue, 17 Aug 2021 15:32:34 +0800 Subject: [PATCH] catch rejection error globally --- server/server.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/server.js b/server/server.js index 6dabcf398..45724494e 100644 --- a/server/server.js +++ b/server/server.js @@ -826,3 +826,9 @@ gracefulShutdown(server, { onShutdown: shutdownFunction, // shutdown function (async) - e.g. for cleanup DB, ... finally: finalFunction, // finally function (sync) - e.g. for logging }); + +// Catch unexpected errors here +process.addListener("unhandledRejection", (error, promise) => { + console.trace(error); + console.error("If you keep encountering errors, please report to https://github.com/louislam/uptime-kuma/issues"); +});