fix(cli): guard process snapshot capture (#3974)

Co-authored-by: heygengenesis[bot] <262951085+heygengenesis[bot]@users.noreply.github.com>
Co-authored-by: miguel.sierra <229591595+miguel-heygen@users.noreply.github.com>
This commit is contained in:
heygengenesis[bot]
2026-09-16 06:33:29 +00:00
committed by GitHub
co-authored by miguel.sierra
parent ef48485b91
commit 08d48ab753
29 changed files with 2098 additions and 230 deletions
@@ -0,0 +1,33 @@
import { EventEmitter } from "node:events";
import { describe, expect, it, vi } from "vitest";
import {
terminateWindowsProcessTree,
windowsProcessTreeKillArgs,
type SpawnProcess,
} from "./processTree.js";
describe("Windows process-tree termination", () => {
it("runs taskkill recursively and forcefully through the platform seam", async () => {
const killer = new EventEmitter();
const spawnProcess = vi.fn<SpawnProcess>(() => killer);
const termination = terminateWindowsProcessTree(4321, spawnProcess);
killer.emit("close", 0);
await termination;
expect(spawnProcess).toHaveBeenCalledWith("taskkill", windowsProcessTreeKillArgs(4321), {
stdio: "ignore",
windowsHide: true,
});
});
it("surfaces taskkill failure so cancellable subprocesses can fall back", async () => {
const killer = new EventEmitter();
const spawnProcess = vi.fn<SpawnProcess>(() => killer);
const termination = terminateWindowsProcessTree(55, spawnProcess);
killer.emit("close", 1);
await expect(termination).rejects.toThrow("taskkill exited with status 1");
});
});