fix(rpc): force taskkill rtt gateway trees on windows

This commit is contained in:
Vincent Koc
2026-06-21 07:23:54 +02:00
parent 5b212162d3
commit ca1aa33eba
2 changed files with 36 additions and 0 deletions

View File

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

View File

@@ -367,6 +367,36 @@ describe("scripts/measure-rpc-rtt.mjs", () => {
expect(child.kill).not.toHaveBeenCalled();
});
it("force-kills Windows gateway process trees when graceful taskkill fails", () => {
const child = Object.assign(new EventEmitter(), {
exitCode: null,
kill: vi.fn(),
pid: 12345,
signalCode: null,
});
const kill = vi.fn(() => true);
const runTaskkill = vi
.fn()
.mockReturnValueOnce({ error: undefined, status: 1 })
.mockReturnValueOnce({ error: undefined, status: 0 });
expect(
signalGatewayProcess(child, "SIGTERM", kill, {
platform: "win32",
runTaskkill,
}),
).toBe(true);
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
stdio: "ignore",
});
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
stdio: "ignore",
});
expect(kill).not.toHaveBeenCalled();
expect(child.kill).not.toHaveBeenCalled();
});
it("treats missing gateway process groups as already exited", () => {
const child = Object.assign(new EventEmitter(), {
exitCode: null,