fix(electron): use tree-kill for electron dev (#5252)

electron process sometimes do not get re-spawned because of some child process not being closed.
use tree-kill instead.
This commit is contained in:
Peng Xiao
2023-12-11 04:26:19 +00:00
parent f0c70b92f4
commit e8cfc807ea
3 changed files with 5 additions and 2 deletions

View File

@@ -63,6 +63,7 @@
"rxjs": "^7.8.1",
"semver": "^7.5.4",
"tinykeys": "^2.1.0",
"tree-kill": "^1.2.2",
"ts-node": "^10.9.1",
"undici": "^6.0.0",
"uuid": "^9.0.1",

View File

@@ -4,6 +4,7 @@ import { resolve } from 'node:path';
import type { ChildProcessWithoutNullStreams } from 'child_process';
import type { BuildContext } from 'esbuild';
import * as esbuild from 'esbuild';
import kill from 'tree-kill';
import { config, electronDir, rootDir } from './common';
@@ -24,9 +25,9 @@ function spawnOrReloadElectron() {
if (watchMode) {
return;
}
if (spawnProcess !== null) {
if (spawnProcess !== null && spawnProcess.pid) {
spawnProcess.off('exit', process.exit);
spawnProcess.kill('SIGINT');
kill(spawnProcess.pid);
spawnProcess = null;
}