Skip to content

Commit 4b2298e

Browse files
committed
fix(package): force taskkill candidate runner trees on windows
1 parent f640ca1 commit 4b2298e

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

scripts/resolve-openclaw-package-candidate.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ export function signalChildProcessTree(
328328
if (!result?.error && result?.status === 0) {
329329
return;
330330
}
331+
if (signal !== "SIGKILL") {
332+
const forceResult = runTaskkill("taskkill", [...args, "/F"], { stdio: "ignore" });
333+
if (!forceResult?.error && forceResult?.status === 0) {
334+
return;
335+
}
336+
}
331337
}
332338
child.kill(signal);
333339
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,30 @@ describe("resolve-openclaw-package-candidate", () => {
240240
expect(child.kill).not.toHaveBeenCalled();
241241
});
242242

243+
it("force-kills Windows package runner process trees when graceful taskkill fails", () => {
244+
const child = {
245+
kill: vi.fn(),
246+
pid: 12345,
247+
};
248+
const runTaskkill = vi
249+
.fn()
250+
.mockReturnValueOnce({ error: undefined, status: 1 })
251+
.mockReturnValueOnce({ error: undefined, status: 0 });
252+
253+
signalChildProcessTree(child, "SIGTERM", {
254+
platform: "win32",
255+
runTaskkill,
256+
});
257+
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+
});
264+
expect(child.kill).not.toHaveBeenCalled();
265+
});
266+
243267
it("keeps npm pack filenames inside the package candidate output directory", async () => {
244268
const dir = await mkdtemp(path.join(tmpdir(), "openclaw-package-npm-pack-"));
245269
tempDirs.push(dir);

0 commit comments

Comments
 (0)