From 639f5bf091d63db82fe2b004faced8e21e9d83fd Mon Sep 17 00:00:00 2001 From: NimBold Date: Thu, 27 Aug 2026 22:45:55 +0330 Subject: [PATCH] fix(startup): defer renderer IPC past load callback (#37) - Issue #37: Windows still overflowed when startup IPC ran from the WebView2 load callback. - Release the renderer startup gate on the next event-loop task after load returns. - Keep logger and console forwarding behind the same post-load boundary. Fixes #37. --- src/main.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main.tsx b/src/main.tsx index ac58c4a..d3b0b54 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -22,11 +22,18 @@ const isPropertiesWindow = getCurrentWindow().label.startsWith('properties-'); // also needed for Zustand persistence, whose module initialization reads the // native database before React mounts. const documentLoaded = new Promise((resolve) => { + const releaseAfterNativeLoad = () => { + // The load event is dispatched from WebView2's navigation callback. Move + // renderer startup to the next task so its first IPC cannot re-enter that + // native callback stack. + window.setTimeout(resolve, 0); + }; + if (document.readyState === 'complete') { - resolve(); + releaseAfterNativeLoad(); return; } - window.addEventListener('load', () => resolve(), { once: true }); + window.addEventListener('load', releaseAfterNativeLoad, { once: true }); }); void documentLoaded.then(() => {