Fix reload race: use main-process webContents.reload() instead of renderer window.location.reload()
The renderer-side window.location.reload() inside executeJavaScript schedules a navigation task asynchronously — the IIFE completes and executeJavaScript resolves before the reload actually starts. This causes waitForDidFinishLoad to see isLoadingMainFrame() as false and resolve immediately, allowing the automation to proceed before the page has reloaded with the seeded state. Move the reload back to the main process via window.webContents.reload(), which synchronously puts the frame into a loading state from the main process perspective.
This commit is contained in:
1 parent
4df79f1c40
commit
e42d1b3d4e
1 file changed
+1
-1
@@ -433,10 +433,10 @@ async function seedRendererState(
|
||||
(() => {
|
||||
const key = "t3code:renderer-state:v7";
|
||||
localStorage.setItem(key, JSON.stringify(${JSON.stringify(state)}));
|
||||
window.location.reload();
|
||||
})();
|
||||
`;
|
||||
await window.webContents.executeJavaScript(script, true);
|
||||
window.webContents.reload();
|
||||
}
|
||||
|
||||
async function readRendererPersistedThreadCount(window: BrowserWindow): Promise<number> {
|
||||
|
||||
Reference in new issue
Block a user