Files
reverse-engineering-anything/src/process/ProcessOwnership.runId.test.ts
T
morluto 09b6828516 fix(process): cancel run-token reads during sampling
Propagate the sample AbortSignal through readProcessRunId to host environment inspection so cancellation can settle a blocked ownership-token read.

Validation: ownership and capture lifecycle suites pass, including an abort-waiting host regression. Native provider runtime behavior was not exercised.
2026-10-12 04:33:42 +08:00

29 lines
950 B
TypeScript

import { expect, it } from "vitest";
import type { ProcessOwnershipHost } from "./ProcessOwnership.js";
import { readProcessRunId } from "./ProcessOwnership.js";
it("passes cancellation through run-token reads", async () => {
const controller = new AbortController();
const cancellation = new Error("cancelled");
const host: ProcessOwnershipHost = {
listProcesses: async () => [],
environment: async (_pid, signal) => {
if (signal === undefined) throw new Error("run-token signal was omitted");
return await new Promise<Readonly<Record<string, string>>>(
(_resolve, reject) => {
signal.addEventListener("abort", () => reject(signal.reason), {
once: true,
});
},
);
},
signalGroup: () => undefined,
};
const reading = readProcessRunId(42, host, controller.signal);
controller.abort(cancellation);
await expect(reading).rejects.toBe(cancellation);
});