Skip to content

Commit 42caa0f

Browse files
fix: use taskkill on Windows for process tree cleanup
process.kill(-pid) is Unix-only; on Windows it fails to kill child processes, causing handle.kill() to hang and the NUT job to timeout. Use taskkill /pid /t /f on Windows for cross-platform process cleanup. Made-with: Cursor
1 parent 58cd165 commit 42caa0f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/commands/webapp/helpers/devServerUtils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { spawn, type ChildProcess } from 'node:child_process';
17+
import { execSync, spawn, type ChildProcess } from 'node:child_process';
1818
import { createServer as createHttpServer, type Server as HttpServer } from 'node:http';
1919
import { join } from 'node:path';
2020
import { createServer, type Server } from 'node:net';
@@ -51,8 +51,14 @@ export function spawnWebappDev(args: string[], options: { cwd: string; timeout?:
5151
let stderrData = '';
5252

5353
const killProcessGroup = (signal: NodeJS.Signals = 'SIGTERM'): void => {
54+
const pid = proc.pid;
55+
if (pid == null) return;
5456
try {
55-
process.kill(-proc.pid!, signal);
57+
if (process.platform === 'win32') {
58+
execSync(`taskkill /pid ${pid} /t /f`, { stdio: 'ignore' });
59+
} else {
60+
process.kill(-pid, signal);
61+
}
5662
} catch {
5763
/* already dead */
5864
}
@@ -90,7 +96,7 @@ export function spawnWebappDev(args: string[], options: { cwd: string; timeout?:
9096
killProcessGroup('SIGKILL');
9197
res();
9298
}, 5_000);
93-
proc.on('close', () => {
99+
proc.once('close', () => {
94100
clearTimeout(forceKillTimeout);
95101
res();
96102
});

0 commit comments

Comments
 (0)