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.
This commit is contained in:
NimBold
2026-08-27 22:45:55 +03:30
parent 97f15dee37
commit 639f5bf091
+9 -2
View File
@@ -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<void>((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(() => {