Skip to content

Commit b15f745

Browse files
committed
fix(package): resolve taskkill from system32 in candidate runner
1 parent 8c9c8aa commit b15f745

2 files changed

Lines changed: 41 additions & 14 deletions

File tree

scripts/resolve-openclaw-package-candidate.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import os from "node:os";
1313
import path from "node:path";
1414
import { pipeline } from "node:stream/promises";
1515
import { fileURLToPath } from "node:url";
16+
import { resolveWindowsTaskkillPath } from "./lib/windows-taskkill.mjs";
1617
import { resolveNpmRunner } from "./npm-runner.mjs";
1718

1819
const ROOT_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
@@ -320,16 +321,17 @@ export function signalChildProcessTree(
320321
}
321322
}
322323
if (platform === "win32" && typeof child.pid === "number") {
324+
const taskkillPath = resolveWindowsTaskkillPath();
323325
const args = ["/PID", String(child.pid), "/T"];
324326
if (signal === "SIGKILL") {
325327
args.push("/F");
326328
}
327-
const result = runTaskkill("taskkill", args, { stdio: "ignore" });
329+
const result = runTaskkill(taskkillPath, args, { stdio: "ignore" });
328330
if (!result?.error && result?.status === 0) {
329331
return;
330332
}
331333
if (signal !== "SIGKILL") {
332-
const forceResult = runTaskkill("taskkill", [...args, "/F"], { stdio: "ignore" });
334+
const forceResult = runTaskkill(taskkillPath, [...args, "/F"], { stdio: "ignore" });
333335
if (!forceResult?.error && forceResult?.status === 0) {
334336
return;
335337
}

test/scripts/resolve-openclaw-package-candidate.test.ts

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { tmpdir } from "node:os";
66
import path from "node:path";
77
import { pathToFileURL } from "node:url";
88
import { afterEach, describe, expect, it, vi } from "vitest";
9+
import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs";
910
import {
1011
ARTIFACT_TARBALL_SCAN_MAX_ENTRIES,
1112
assertExpectedSha256ForTest,
@@ -24,6 +25,10 @@ import {
2425
validateOpenClawPackageSpec,
2526
} from "../../scripts/resolve-openclaw-package-candidate.mjs";
2627

28+
function expectedTaskkillPath(): string {
29+
return resolveWindowsTaskkillPath();
30+
}
31+
2732
const tempDirs: string[] = [];
2833

2934
type LookupAddress = { address: string; family: number };
@@ -226,17 +231,27 @@ describe("resolve-openclaw-package-candidate", () => {
226231
platform: "win32",
227232
runTaskkill,
228233
});
229-
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
230-
stdio: "ignore",
231-
});
234+
expect(runTaskkill).toHaveBeenNthCalledWith(
235+
1,
236+
expectedTaskkillPath(),
237+
["/PID", "12345", "/T"],
238+
{
239+
stdio: "ignore",
240+
},
241+
);
232242

233243
signalChildProcessTree(child, "SIGKILL", {
234244
platform: "win32",
235245
runTaskkill,
236246
});
237-
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
238-
stdio: "ignore",
239-
});
247+
expect(runTaskkill).toHaveBeenNthCalledWith(
248+
2,
249+
expectedTaskkillPath(),
250+
["/PID", "12345", "/T", "/F"],
251+
{
252+
stdio: "ignore",
253+
},
254+
);
240255
expect(child.kill).not.toHaveBeenCalled();
241256
});
242257

@@ -255,12 +270,22 @@ describe("resolve-openclaw-package-candidate", () => {
255270
runTaskkill,
256271
});
257272

258-
expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], {
259-
stdio: "ignore",
260-
});
261-
expect(runTaskkill).toHaveBeenNthCalledWith(2, "taskkill", ["/PID", "12345", "/T", "/F"], {
262-
stdio: "ignore",
263-
});
273+
expect(runTaskkill).toHaveBeenNthCalledWith(
274+
1,
275+
expectedTaskkillPath(),
276+
["/PID", "12345", "/T"],
277+
{
278+
stdio: "ignore",
279+
},
280+
);
281+
expect(runTaskkill).toHaveBeenNthCalledWith(
282+
2,
283+
expectedTaskkillPath(),
284+
["/PID", "12345", "/T", "/F"],
285+
{
286+
stdio: "ignore",
287+
},
288+
);
264289
expect(child.kill).not.toHaveBeenCalled();
265290
});
266291

0 commit comments

Comments
 (0)