vite-plugin-electron: Restart does not close old Electron instance
Problem
My app has a before-quit handler which waits for the webview to be ready. But when the plugin makes Electron restart, the webview page/code is gone, so it can’t tell the app to finish quitting. This means I end up with many Electron instances running at the same time
Solution
Keep the Vite webpage loaded until the app quits
Workaround
Disable restarting:
onstart({ startup }) {
if (process.electronApp) {
console.log('\x1b[35mNot restarting\x1b[0m')
} else {
startup()
}
}
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 26 (11 by maintainers)
Commits related to this issue
- feat: force exit app #251 — committed to electron-vite/vite-plugin-electron by caoxiemeihao 2 years ago
- fix: better exit app #251 — committed to electron-vite/vite-plugin-electron by caoxiemeihao 2 years ago
- fix: better tree kill logic #251 — committed to electron-vite/vite-plugin-electron by caoxiemeihao 2 years ago
vite-plugin-electron v0.28.8 vite v5.3.1
In mac, when I make modifications in the main process main.js, the BrowserWindow instance of electron will be re-created, What should I do?
Yes I do have the problem on the latest version (v0.28.7).
However, it works if I call
treeKillSyncin my own Vite config, or even justprocess.kill(process.electronApp.pid):It would be neat if it did a graceful shutdown with
SIGTERMby waiting for the child_process to exit