You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
plugin-vite: electron-forge start loads the renderer twice, as the first preload build sends a full-reload #4439
The terminal prints did-finish-load twice, in 3 runs out of 3.
Additional information
The preload's watch build sends reload-renderers from closeBundle on every build, the first one included (dist/subprocess-worker.js, target === 'preload'), and VitePlugin turns it into server.ws.send({ type: 'full-reload' }). On the first build Electron has not started yet, so no client is connected. Vite (8.3.3 here) keeps a full-reload that finds no client and sends it to the first client that connects (bufferedMessage in its createWebSocketServer), so the first page reloads right after it connects.
Not sending reload-renderers for the first build would fix it. Our workaround, a plugin in the renderer's Vite config:
It's making my startup logic, which involves RxJS Observables in the main process, with Observers that bridge them to IPC events, quite tricky -- initial events get sent when the window is created, and the original renderer process gets them, but the reloaded renderer process doesn't, because the window still exists and the main process doesn't know it was reloaded. My workaround is to have the renderer code post an explicit "OK, I'm ready now" event back to the main process, but it's messy, and I'm not sure there isn't still a race condition in there somewhere.
Knowing that it only happens on the first load, though (and only in development), till the fix is in place, I may take that explicit event out and go back to trying to register the observers at an appropriate point in the window lifecycle — and just accept that I need to hit r in the terminal before I get the application in a consistent state. 🤷
Activity
fix(plugin-vite): don't reload renderers after the first preload build
dmoles commentedon Oct 28, 2026
I'm seeing this as well, FWIW:
It's making my startup logic, which involves RxJS Observables in the main process, with Observers that bridge them to IPC events, quite tricky -- initial events get sent when the window is created, and the original renderer process gets them, but the reloaded renderer process doesn't, because the window still exists and the main process doesn't know it was reloaded. My workaround is to have the renderer code post an explicit "OK, I'm ready now" event back to the main process, but it's messy, and I'm not sure there isn't still a race condition in there somewhere.
Knowing that it only happens on the first load, though (and only in development), till the fix is in place, I may take that explicit event out and go back to trying to register the observers at an appropriate point in the window lifecycle — and just accept that I need to hit
rin the terminal before I get the application in a consistent state. 🤷fix(plugin-vite): don't reload renderers after the first preload build