mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 18:05:45 +00:00
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.
29 lines
950 B
TypeScript
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);
|
|
});
|