From 0a1181fecd94bd711b90d34af1fa2becf7677e21 Mon Sep 17 00:00:00 2001 From: Misaka Date: Fri, 3 Apr 2026 21:13:36 +0800 Subject: [PATCH] fix(logger): use will-quit instead of before-quit and remove redundant console.error Move logger close from before-quit to will-quit to keep the logger available for uncaughtException handlers that may fire during shutdown. Remove 4 redundant console.error calls that duplicate Winston logger output. Co-Authored-By: Claude Opus 4.6 --- src/main/bootstrap/process-guards.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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() })