fix(core): use process#kill instead of tree-kill for windows and macos (#30976)

Prefer `process#kill` instead of `tree-kill` for Mac and Windows. This
fixes an issue on Windows where the `taskkill` is unsuccessful.

## Current Behavior
Windows does not always run successfully

## Expected Behavior
Windows runs successfully

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jack Hsu 2025-05-01 16:35:22 -04:00 committed by GitHub
parent 1029ecb9fd
commit 7b9add5582
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 10 deletions

View File

@ -93,12 +93,20 @@ function startWebServer(webServerCommand: string) {
} }
} else { } else {
return new Promise<void>((res, rej) => { return new Promise<void>((res, rej) => {
treeKill(serverProcess.pid, (err) => { if (process.platform === 'win32' || process.platform === 'darwin') {
if (err) { if (this.childProcess.kill()) {
rej(err); res();
} else {
rej('Unable to kill process');
} }
res(); } else {
}); treeKill(serverProcess.pid, (err) => {
if (err) {
rej(err);
}
res();
});
}
}); });
} }
}; };

View File

@ -359,13 +359,21 @@ class RunningNodeProcess implements RunningTask {
kill(signal?: NodeJS.Signals | number): Promise<void> { kill(signal?: NodeJS.Signals | number): Promise<void> {
return new Promise<void>((res, rej) => { return new Promise<void>((res, rej) => {
treeKill(this.childProcess.pid, signal, (err) => { if (process.platform === 'win32' || process.platform === 'darwin') {
if (err) { if (this.childProcess.kill(signal)) {
rej(err);
} else {
res(); res();
} else {
rej('Unable to kill process');
} }
}); } else {
treeKill(this.childProcess.pid, signal, (err) => {
if (err) {
rej(err);
} else {
res();
}
});
}
}); });
} }