From 7dbae1b2cd3009b0acca1db6eb8d1035582fbe4b Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 09:44:37 +0200 Subject: [PATCH] fix(scripts): resolve taskkill in boundary artifacts --- ...e-extension-package-boundary-artifacts.mjs | 6 ++- ...tension-package-boundary-artifacts.test.ts | 49 ++++++++++++++----- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/scripts/prepare-extension-package-boundary-artifacts.mjs b/scripts/prepare-extension-package-boundary-artifacts.mjs index abc52eefccb0..2bf43fb72a9f 100644 --- a/scripts/prepare-extension-package-boundary-artifacts.mjs +++ b/scripts/prepare-extension-package-boundary-artifacts.mjs @@ -6,6 +6,7 @@ import path, { resolve } from "node:path"; import { isLocalCheckEnabled } from "./lib/local-heavy-check-runtime.mjs"; import { parsePositiveInt } from "./lib/numeric-options.mjs"; import { pluginSdkEntrypoints, publicPluginSdkEntrypoints } from "./lib/plugin-sdk-entries.mjs"; +import { resolveWindowsTaskkillPath } from "./lib/windows-taskkill.mjs"; const repoRoot = resolve(import.meta.dirname, ".."); const runTsgoScript = path.join(repoRoot, "scripts/run-tsgo.mjs"); @@ -421,12 +422,13 @@ export function signalNodeStep( if (signal === "SIGKILL") { args.push("/F"); } - const result = runTaskkill("taskkill", args, { stdio: "ignore" }); + const taskkillPath = resolveWindowsTaskkillPath(); + const result = runTaskkill(taskkillPath, args, { stdio: "ignore" }); if (!result?.error && result?.status === 0) { return; } if (signal !== "SIGKILL") { - const forceResult = runTaskkill("taskkill", [...args, "/F"], { stdio: "ignore" }); + const forceResult = runTaskkill(taskkillPath, [...args, "/F"], { stdio: "ignore" }); if (!forceResult?.error && forceResult?.status === 0) { return; } diff --git a/test/scripts/prepare-extension-package-boundary-artifacts.test.ts b/test/scripts/prepare-extension-package-boundary-artifacts.test.ts index 6a303c054ce5..9e18a5b8352b 100644 --- a/test/scripts/prepare-extension-package-boundary-artifacts.test.ts +++ b/test/scripts/prepare-extension-package-boundary-artifacts.test.ts @@ -8,6 +8,7 @@ import path from "node:path"; import { setTimeout as delay } from "node:timers/promises"; import { pathToFileURL } from "node:url"; import { afterEach, describe, expect, it, vi } from "vitest"; +import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs"; import { createPrefixedOutputWriter, isArtifactSetFresh, @@ -23,6 +24,10 @@ import { makeTempDir } from "../helpers/temp-dir.js"; const tempRoots = new Set(); +function expectedTaskkillPath(): string { + return resolveWindowsTaskkillPath(); +} + function createMockPipe() { const pipe = new EventEmitter() as EventEmitter & { setEncoding: (encoding: string) => void; @@ -135,17 +140,27 @@ describe("prepare-extension-package-boundary-artifacts", () => { platform: "win32", runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 1, + expectedTaskkillPath(), + ["/PID", "12345", "/T"], + { + stdio: "ignore", + }, + ); signalNodeStep(child, "SIGKILL", { platform: "win32", runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 2, + expectedTaskkillPath(), + ["/PID", "12345", "/T", "/F"], + { + stdio: "ignore", + }, + ); expect(child.kill).not.toHaveBeenCalled(); }); @@ -164,12 +179,22 @@ describe("prepare-extension-package-boundary-artifacts", () => { runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], { - stdio: "ignore", - }); - expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 1, + expectedTaskkillPath(), + ["/PID", "12345", "/T"], + { + stdio: "ignore", + }, + ); + expect(runTaskkill).toHaveBeenNthCalledWith( + 2, + expectedTaskkillPath(), + ["/PID", "12345", "/T", "/F"], + { + stdio: "ignore", + }, + ); expect(child.kill).not.toHaveBeenCalled(); });