fix(scripts): kill boundary prep trees on windows

This commit is contained in:
Vincent Koc
2026-06-21 06:34:10 +02:00
parent 5af318b95d
commit b0f21f8af7
2 changed files with 51 additions and 6 deletions

View File

@@ -7,7 +7,7 @@ import os from "node:os";
import path from "node:path";
import { setTimeout as delay } from "node:timers/promises";
import { pathToFileURL } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
createPrefixedOutputWriter,
isArtifactSetFresh,
@@ -17,6 +17,7 @@ import {
runNodeStep,
runNodeSteps,
runNodeStepsInParallel,
signalNodeStep,
} from "../../scripts/prepare-extension-package-boundary-artifacts.mjs";
import { makeTempDir } from "../helpers/temp-dir.js";
@@ -123,6 +124,31 @@ describe("prepare-extension-package-boundary-artifacts", () => {
expect(Date.now() - startedAt).toBeLessThan(abortBudgetMs);
}, 45_000);
it("signals Windows node step process trees with taskkill", () => {
const child = {
kill: vi.fn(),
pid: 12345,
};
const runTaskkill = vi.fn(() => ({ error: undefined, status: 0 }));
signalNodeStep(child, "SIGTERM", {
platform: "win32",
runTaskkill,
});
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
stdio: "ignore",
});
signalNodeStep(child, "SIGKILL", {
platform: "win32",
runTaskkill,
});
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 () => {