Fix bug on Linux where hot reload in src/main file froze window

When a file in src/main is changed the vite-plugin-electron will kill
the electron process and restart it. However, on Linux it seems like
the electron window process freezes if we do that.

Killing the main electron process seems to kill all its children, on Linux.
We will manually kill the process children before the parent process
on macOS as the current implementation seems to work well on that platform.
This commit is contained in:
Tobias Järvelöv
2026-03-12 14:32:38 +01:00
parent 30db93ee24
commit 280228a78e

View File

@@ -41,9 +41,11 @@ function pidTree(tree: PidTree) {
}
function killTree(tree: PidTree) {
if (tree.children) {
for (const child of tree.children) {
killTree(child);
if (process.platform === 'darwin') {
if (tree.children) {
for (const child of tree.children) {
killTree(child);
}
}
}