fix(scripts): force taskkill boundary node steps on windows

This commit is contained in:
Vincent Koc
2026-06-21 07:36:02 +02:00
parent 4b2298e8cb
commit 4d17a52924
2 changed files with 30 additions and 0 deletions

View File

@@ -425,6 +425,12 @@ export function signalNodeStep(
if (!result?.error && result?.status === 0) {
return;
}
if (signal !== "SIGKILL") {
const forceResult = runTaskkill("taskkill", [...args, "/F"], { stdio: "ignore" });
if (!forceResult?.error && forceResult?.status === 0) {
return;
}
}
}
child.kill(signal);
}

View File

@@ -149,6 +149,30 @@ describe("prepare-extension-package-boundary-artifacts", () => {
expect(child.kill).not.toHaveBeenCalled();
});
it("force-kills Windows node step process trees when graceful taskkill fails", () => {
const child = {
kill: vi.fn(),
pid: 12345,
};
const runTaskkill = vi
.fn()
.mockReturnValueOnce({ error: undefined, status: 1 })
.mockReturnValueOnce({ error: undefined, status: 0 });
signalNodeStep(child, "SIGTERM", {
platform: "win32",
runTaskkill,
});
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
stdio: "ignore",
});
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
stdio: "ignore",
});
expect(child.kill).not.toHaveBeenCalled();
});
it.runIf(process.platform !== "win32")(
"force-kills aborted sibling step process groups",
async () => {