From 5718bf8a7c0f22794f0daafb5d3c3c2b8dee1a51 Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 17 Jul 2024 19:16:09 -0700 Subject: [PATCH] fix uncaught exception popup --- emain/emain.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/emain/emain.ts b/emain/emain.ts index a07c8888c..1621affba 100644 --- a/emain/emain.ts +++ b/emain/emain.ts @@ -575,6 +575,28 @@ function makeAppMenu() { electron.app.on("before-quit", () => { globalIsQuitting = true; }); +process.on("SIGINT", () => { + console.log("Caught SIGINT, shutting down"); + electron.app.quit(); +}); +process.on("SIGHUP", () => { + console.log("Caught SIGHUP, shutting down"); + electron.app.quit(); +}); +process.on("SIGTERM", () => { + console.log("Caught SIGTERM, shutting down"); + electron.app.quit(); +}); +let caughtException = false; +process.on("uncaughtException", (error) => { + if (caughtException) { + return; + } + logger.error("Uncaught Exception, shutting down: ", error); + caughtException = true; + // Optionally, handle cleanup or exit the app + electron.app.quit(); +}); async function appMain() { const startTs = Date.now();