diff --git a/src/node/entry.ts b/src/node/entry.ts index 5869ae46..dfd78cda 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -18,13 +18,6 @@ import { loadPlugins } from "./plugin" import { generateCertificate, hash, humanPath, open } from "./util" import { ipcMain, wrap } from "./wrapper" -process.on("uncaughtException", (error) => { - logger.error(`Uncaught exception: ${error.message}`) - if (typeof error.stack !== "undefined") { - logger.error(error.stack) - } -}) - let pkg: { version?: string; commit?: string } = {} try { pkg = require("../../package.json") diff --git a/src/node/wrapper.ts b/src/node/wrapper.ts index ba459efd..2f1eb037 100644 --- a/src/node/wrapper.ts +++ b/src/node/wrapper.ts @@ -254,6 +254,14 @@ if (!process.stdout.isTTY) { process.stdout.on("error", () => ipcMain().exit()) } +// Don't let uncaught exceptions crash the process. +process.on("uncaughtException", (error) => { + logger.error(`Uncaught exception: ${error.message}`) + if (typeof error.stack !== "undefined") { + logger.error(error.stack) + } +}) + export const wrap = (fn: () => Promise): void => { if (ipcMain().parentPid) { ipcMain()