diff --git a/scripts/e2e/telegram-user-credential-io.ts b/scripts/e2e/telegram-user-credential-io.ts index 7d142e6a0720..b509b695e116 100644 --- a/scripts/e2e/telegram-user-credential-io.ts +++ b/scripts/e2e/telegram-user-credential-io.ts @@ -1,6 +1,7 @@ // Telegram User Credential Io script supports OpenClaw repository automation. import { spawn, spawnSync } from "node:child_process"; import { readBoundedResponseText } from "../lib/bounded-response.ts"; +import { resolveWindowsTaskkillPath } from "../lib/windows-taskkill.mjs"; export type JsonObject = Record; @@ -272,12 +273,13 @@ export function signalChildProcessTree( 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/telegram-user-credential.test.ts b/test/scripts/telegram-user-credential.test.ts index a0c44006250c..9fa709f74086 100644 --- a/test/scripts/telegram-user-credential.test.ts +++ b/test/scripts/telegram-user-credential.test.ts @@ -15,10 +15,15 @@ import { resolvePrivateJsonDirectory, writePrivateJson, } from "../../scripts/e2e/telegram-user-credential-paths.ts"; +import { resolveWindowsTaskkillPath } from "../../scripts/lib/windows-taskkill.mjs"; const tempDirs: string[] = []; const CHUNKED_PAYLOAD_MARKER = "__openclawQaCredentialPayloadChunksV1"; +function expectedTaskkillPath(): string { + return resolveWindowsTaskkillPath(); +} + function makeTempDir(prefix: string) { const dir = mkdtempSync(path.join(tmpdir(), prefix)); tempDirs.push(dir); @@ -418,17 +423,27 @@ setInterval(() => {}, 1000); platform: "win32", runTaskkill, }); - expect(runTaskkill).toHaveBeenNthCalledWith(1, "taskkill", ["/PID", "12345", "/T"], { - stdio: "ignore", - }); + expect(runTaskkill).toHaveBeenNthCalledWith( + 1, + expectedTaskkillPath(), + ["/PID", "12345", "/T"], + { + stdio: "ignore", + }, + ); signalChildProcessTree(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(); }); @@ -447,12 +462,22 @@ setInterval(() => {}, 1000); 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(); });