diff --git a/src/main/bootstrap/process-guards.ts b/src/main/bootstrap/process-guards.ts index 91a8700..ff24df3 100644 --- a/src/main/bootstrap/process-guards.ts +++ b/src/main/bootstrap/process-guards.ts @@ -12,7 +12,6 @@ export function setupProcessGuards(): void { status: 'failure', metadata: { error: err.message, stack: err.stack } }) - console.error('Uncaught exception:', err) setTimeout(() => process.exit(1), 1000) }) @@ -25,21 +24,21 @@ export function setupProcessGuards(): void { status: 'failure', metadata: { reason: String(reason) } }) - console.error('Unhandled Rejection:', reason) }) app.on('render-process-gone', (_, webContents, details) => { logger.error('Render process gone', { details, webContentsId: webContents.id }) - console.error('Render process gone:', details) }) app.on('child-process-gone', (_, details) => { logger.error('Child process gone', { details }) - console.error('Child process gone:', details) }) - // Flush and close loggers before quit to prevent log loss - app.on('before-quit', () => { + // Flush and close loggers on will-quit (fires after all windows are closed, + // but before the event loop stops). Using will-quit instead of before-quit + // ensures the logger remains available for uncaughtException handlers that + // may fire between before-quit and actual process exit. + app.on('will-quit', () => { logger.close() closeAuditLogger() })