From afd55e112b8dd94d20936285e479d685ba3757e2 Mon Sep 17 00:00:00 2001 From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:42:29 +0100 Subject: [PATCH] fix: use destroy() for splash screen to avoid WebContents race When the splash screen closes via close(), Electron's internal sandboxed renderer scripts may still be executing. These scripts can try to access webContents properties after destruction, causing: - BROWSER_GET_LAST_WEB_PREFERENCES: WebContents does not exist - sandboxed_renderer.bundle.js script failed to run - TypeError: object null is not iterable Using destroy() immediately destroys the window without waiting for internal scripts to complete. This is appropriate for the splash since it has no state to preserve and no close handlers that need to run. Also adds isDestroyed() guard in notify.ts for notification click handlers that could fire after window destruction. --- src/desktop/main.ts | 5 ++++- src/node/services/tools/notify.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/desktop/main.ts b/src/desktop/main.ts index a19b0a44b9..c856ba8699 100644 --- a/src/desktop/main.ts +++ b/src/desktop/main.ts @@ -286,8 +286,11 @@ async function showSplashScreen() { function closeSplashScreen() { if (splashWindow) { console.log(`[${timestamp()}] Closing splash screen...`); - splashWindow.close(); + const win = splashWindow; splashWindow = null; + if (!win.isDestroyed()) { + win.destroy(); // Immediate destruction - avoids race with internal renderer scripts + } } } diff --git a/src/node/services/tools/notify.ts b/src/node/services/tools/notify.ts index 960955ebf3..0d85d89c83 100644 --- a/src/node/services/tools/notify.ts +++ b/src/node/services/tools/notify.ts @@ -76,7 +76,7 @@ async function sendElectronNotification( notification.on("click", () => { const windows = BrowserWindow.getAllWindows(); const mainWindow = windows[0]; - if (mainWindow) { + if (mainWindow && !mainWindow.isDestroyed()) { // Restore if minimized, then focus if (mainWindow.isMinimized()) { mainWindow.restore();