From eca57c85ef77e84d30e797b3553bfc751ee728bb Mon Sep 17 00:00:00 2001 From: Brenden Blosser Date: Fri, 3 Jul 2026 10:19:53 -0400 Subject: [PATCH] Fix blank window when reopening after the main window is destroyed registerSpellcheck()'s invoke-handler registration guard checked ipcMain.eventNames(), which only reflects .on()/.once() listeners -- handlers registered via ipcMain.handle() never show up there, so the guard was a no-op. With closeToTray disabled (or any other path that lets the main window actually close instead of hide), a second createWindow() call would hit "Attempted to register a second handler for 'spellcheck-get-state'", aborting window setup partway through and leaving a blank window. Use a real module-level flag instead, matching the pattern already used for this file's .on() listeners. --- fluxer_desktop/src/main/Spellcheck.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fluxer_desktop/src/main/Spellcheck.ts b/fluxer_desktop/src/main/Spellcheck.ts index 01473a7..262272a 100644 --- a/fluxer_desktop/src/main/Spellcheck.ts +++ b/fluxer_desktop/src/main/Spellcheck.ts @@ -133,6 +133,7 @@ const dictionaryDataPromises = new Map | null = null; let ipcRegistered = false; +let invokeHandlersRegistered = false; let launchModeLogged = false; const contextSourceByWebContents = new WeakMap< @@ -1060,7 +1061,8 @@ export const registerSpellcheck = (webContents: WebContents): void => { return state; }; void applyAndBroadcast(false); - if (!ipcMain.eventNames().includes('spellcheck-get-state')) { + if (!invokeHandlersRegistered) { + invokeHandlersRegistered = true; ipcMain.handle('spellcheck-get-state', (event) => { const targetSession = event.sender.session; const next = applyLaunchSpellcheckMode(sessionState.get(targetSession) ?? {...defaultState});