mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 20:53:00 +00:00
* test(lifecycle): cover browser-transport handshakes and cleanup retry Close six provider lifecycle gaps: Electron CDP handshake, cleanup and retry; V8 inspector handshake; web-module-trace handshake and retry. * test(lifecycle): assert retained cleanup finishes before the next acquisition Hold the retried browser and Electron transport close and check that no replacement launch or connect starts until it completes. Track gated upgrade sockets in the fake CDP browser so close() destroys them. * test(lifecycle): release held retry gates and join gated work on failure Teardown for the resolver and Electron retry tests releases the held close and awaits the gated request even when an assertion fails while it is held. * test(lifecycle): cover worker and tool launch, worker handshake, and decoder completion (#11512) * test(lifecycle): cover worker and tool launch, worker handshake, and decoder completion Close six provider lifecycle gaps: SQLite and JavaScript worker launch, JavaScript worker handshake, assetutil launch, and qlog and mitmproxy decoding through the owned decoder child. * test(lifecycle): run the worker relaunch in a built project and check exits before close The relaunch starts the built worker entry, so it moves to tests/boundary/javascript. The handshake tests now check that the stand-in child has exited when analyze() returns, before close() runs. * test(lifecycle): cover in-process cancellation and PE certificate completion (#11524) * test(lifecycle): cover in-process cancellation and PE certificate completion Close six provider lifecycle gaps: caller cancellation for the managed, Harmony, JavaScript workflow, runtime reconciliation and V8 code cache providers, and PE certificate completion (an existing CLI/MCP regression). Two Apple application gaps remain (#11509). * test(lifecycle): compare the whole retained V8 code cache observation * test(javascript): hold the startup deadline clock until the stand-in worker is running * test(javascript): restore real timers in a void teardown * test(lifecycle): join the held Electron request on failure, refuse unmodeled Inspector commands, drop a wording assertion * fix(apple): run assetutil under owned process supervision and retain unproven cleanup (#11586) * fix(process): report a cancellation or deadline during refused final cleanup as that interruption * fix(apple): prepare ownership before the assetutil deadline, keep per-stream allowances, join interrupted-cleanup tests * fix(artifacts): classify assetutil launch failures through the shared launch owner After #11615, owned-command launch failures are one launch-failed outcome classified by the shared owner. The assetutil dialect keeps only its unavailable report (launchUnavailable) and names its provider; host capacity and E2BIG become resource constraints. * fix(artifacts): keep a completed assetutil run's output on its cleanup-only report When assetutil exits 0 but its process cleanup is unproven, the cleanup error is the primary report. retainOwnedCommandCleanup now accepts the completed run's captured output for such a caller, so CLI and MCP keep the retained output beside the cleanup owner.
595 lines
19 KiB
TypeScript
595 lines
19 KiB
TypeScript
import { EventEmitter } from "node:events";
|
|
import { PassThrough, Writable } from "node:stream";
|
|
import { expect, it, vi } from "vitest";
|
|
|
|
import { createDeferred } from "../../tests/fixtures/binarySession.js";
|
|
import { awaitAcknowledgement } from "../../tests/fixtures/lifecycleAcknowledgement.js";
|
|
import { OwnedCommandFailure, runOwnedCommand } from "./OwnedCommand.js";
|
|
import type { ProcessCleanupResult } from "./ProcessOwnership.js";
|
|
|
|
class CommandChild extends EventEmitter {
|
|
readonly stdout = new PassThrough();
|
|
readonly stderr = new PassThrough();
|
|
readonly kill = vi.fn(() => false);
|
|
exitCode: number | null = null;
|
|
readonly signalCode = null;
|
|
|
|
constructor(readonly stdin: Writable | null) {
|
|
super();
|
|
}
|
|
|
|
complete(): void {
|
|
if (this.exitCode !== null) return;
|
|
this.exitCode = 0;
|
|
this.stdout.end();
|
|
this.stderr.end();
|
|
this.emit("exit", 0, null);
|
|
this.emit("close", 0, null);
|
|
}
|
|
}
|
|
|
|
const ownedInput = (input: Writable | null) => {
|
|
const child = new CommandChild(input);
|
|
const ownership = {
|
|
runId: "authored-command-input",
|
|
leaderPid: 41234,
|
|
processGroupId: 41234,
|
|
};
|
|
const cleanup = vi.fn(async (): Promise<ProcessCleanupResult> => {
|
|
input?.destroy();
|
|
child.complete();
|
|
return { cleaned: true, signaled: false };
|
|
});
|
|
return { child, ownership, cleanup };
|
|
};
|
|
|
|
const spawn = {
|
|
command: "authored-command",
|
|
arguments: [],
|
|
runId: "authored-command-input",
|
|
};
|
|
|
|
it("captures synchronous EOF output after supervision and interprets it before cleanup", async () => {
|
|
const stages: string[] = [];
|
|
const input = new Writable({
|
|
final(callback) {
|
|
stages.push("input-final");
|
|
fixture.child.stdout.write("EOF output");
|
|
fixture.child.stderr.write("EOF diagnostic");
|
|
fixture.child.complete();
|
|
callback();
|
|
},
|
|
});
|
|
const fixture = ownedInput(input);
|
|
const cleanup = fixture.cleanup.getMockImplementation()!;
|
|
fixture.cleanup.mockImplementation(async () => {
|
|
stages.push("cleanup");
|
|
return cleanup();
|
|
});
|
|
const snapshot = await runOwnedCommand(
|
|
spawn,
|
|
{
|
|
timeoutMs: null,
|
|
diagnosticBytes: 1024,
|
|
stdin: "closed-pipe",
|
|
observeCompleted: () => stages.push("observed"),
|
|
},
|
|
{
|
|
launcher: async (request) => {
|
|
expect(request.stdin).toBe("pipe");
|
|
expect(input.writableEnded).toBe(false);
|
|
return {
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
};
|
|
},
|
|
},
|
|
);
|
|
expect(snapshot).toMatchObject({
|
|
exitCode: 0,
|
|
stdout: { text: "EOF output" },
|
|
stderr: { text: "EOF diagnostic" },
|
|
});
|
|
expect(stages).toEqual(["input-final", "observed", "cleanup"]);
|
|
expect(fixture.child.kill).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("waits for delayed input finalization after output closes", async () => {
|
|
const controller = new AbortController();
|
|
const finalizing = createDeferred<void>();
|
|
let finishInput: () => void = () => {};
|
|
const input = new Writable({
|
|
final(callback) {
|
|
finishInput = callback;
|
|
fixture.child.complete();
|
|
finalizing.resolve();
|
|
},
|
|
});
|
|
const fixture = ownedInput(input);
|
|
const observeCompleted = vi.fn();
|
|
const pending = runOwnedCommand(
|
|
spawn,
|
|
{
|
|
timeoutMs: null,
|
|
diagnosticBytes: 1024,
|
|
stdin: "closed-pipe",
|
|
observeCompleted,
|
|
},
|
|
{
|
|
signal: controller.signal,
|
|
launcher: async () => ({
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
}),
|
|
},
|
|
);
|
|
try {
|
|
await awaitAcknowledgement(
|
|
finalizing.promise,
|
|
pending,
|
|
"input finalization",
|
|
);
|
|
await new Promise<void>((resolve) => setImmediate(resolve));
|
|
expect(observeCompleted).not.toHaveBeenCalled();
|
|
expect(fixture.cleanup).not.toHaveBeenCalled();
|
|
const finish = finishInput;
|
|
finishInput = () => {};
|
|
finish();
|
|
await expect(pending).resolves.toMatchObject({ exitCode: 0 });
|
|
expect(observeCompleted).toHaveBeenCalledOnce();
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
} finally {
|
|
controller.abort();
|
|
finishInput();
|
|
await pending.catch(() => undefined);
|
|
}
|
|
});
|
|
|
|
it.each([2_000, null])(
|
|
"cancels delayed input finalization with the opaque caller reason (timeout %s)",
|
|
async (timeoutMs) => {
|
|
const controller = new AbortController();
|
|
const reason = new OwnedCommandFailure("timeout", "opaque caller reason");
|
|
const finalizing = createDeferred<void>();
|
|
const input = new Writable({
|
|
final(_callback) {
|
|
fixture.child.complete();
|
|
finalizing.resolve();
|
|
},
|
|
});
|
|
const fixture = ownedInput(input);
|
|
const observeCompleted = vi.fn();
|
|
const pending = runOwnedCommand(
|
|
spawn,
|
|
{
|
|
timeoutMs,
|
|
diagnosticBytes: 1024,
|
|
stdin: "closed-pipe",
|
|
observeCompleted,
|
|
},
|
|
{
|
|
signal: controller.signal,
|
|
launcher: async () => ({
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
}),
|
|
},
|
|
);
|
|
const rejected = expect(pending).rejects.toMatchObject({
|
|
reason: "cancelled",
|
|
cancellation: { reason },
|
|
cleanupFailure: null,
|
|
});
|
|
try {
|
|
await awaitAcknowledgement(
|
|
finalizing.promise,
|
|
pending,
|
|
"input finalization",
|
|
);
|
|
controller.abort(reason);
|
|
await rejected;
|
|
expect(observeCompleted).not.toHaveBeenCalled();
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
expect(input.destroyed).toBe(true);
|
|
expect(fixture.child.kill).not.toHaveBeenCalled();
|
|
} finally {
|
|
controller.abort(reason);
|
|
await pending.catch(() => undefined);
|
|
}
|
|
},
|
|
);
|
|
|
|
it.each([undefined, null, new Error("synchronous end failure")])(
|
|
"preserves a synchronous input end rejection as a physical collection failure: %j",
|
|
async (reason) => {
|
|
const input = new Writable();
|
|
vi.spyOn(input, "end").mockImplementation(() => {
|
|
throw reason;
|
|
});
|
|
const fixture = ownedInput(input);
|
|
const failure: unknown = await runOwnedCommand(
|
|
spawn,
|
|
{ timeoutMs: null, diagnosticBytes: 1024, stdin: "closed-pipe" },
|
|
{
|
|
launcher: async () => ({
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
}),
|
|
},
|
|
).catch((cause: unknown) => cause);
|
|
if (!(failure instanceof OwnedCommandFailure)) throw failure;
|
|
expect(failure.reason).toBe("process");
|
|
expect(failure.collectionFailure).toBe(true);
|
|
expect(failure.cause).toBeInstanceOf(OwnedCommandFailure);
|
|
expect(failure.cause).toHaveProperty("cause", reason);
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
},
|
|
);
|
|
|
|
it("keeps an asynchronous input error primary before same-turn cancellation", async () => {
|
|
const controller = new AbortController();
|
|
const inputError = new Error("authored input failure");
|
|
const reason = { request: "abort after physical input error" };
|
|
const input = new Writable({
|
|
final(_callback) {
|
|
setImmediate(() => {
|
|
input.emit("error", inputError);
|
|
controller.abort(reason);
|
|
});
|
|
},
|
|
});
|
|
const fixture = ownedInput(input);
|
|
const failure: unknown = await runOwnedCommand(
|
|
spawn,
|
|
{ timeoutMs: null, diagnosticBytes: 1024, stdin: "closed-pipe" },
|
|
{
|
|
signal: controller.signal,
|
|
launcher: async () => ({
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
}),
|
|
},
|
|
).catch((cause: unknown) => cause);
|
|
if (!(failure instanceof OwnedCommandFailure)) throw failure;
|
|
expect(failure).toMatchObject({
|
|
reason: "process",
|
|
collectionFailure: true,
|
|
processError: inputError,
|
|
});
|
|
expect(failure.cancellation?.reason).toBe(reason);
|
|
expect(failure.cause).toHaveProperty("cause", inputError);
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("collects an asynchronous Writable final callback error before process cleanup", async () => {
|
|
const inputError = new Error("asynchronous final callback failure");
|
|
const input = new Writable({
|
|
final(callback) {
|
|
setImmediate(() => callback(inputError));
|
|
},
|
|
});
|
|
const fixture = ownedInput(input);
|
|
const failure: unknown = await runOwnedCommand(
|
|
spawn,
|
|
{ timeoutMs: null, diagnosticBytes: 1024, stdin: "closed-pipe" },
|
|
{
|
|
launcher: async () => ({
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
}),
|
|
},
|
|
).catch((cause: unknown) => cause);
|
|
if (!(failure instanceof OwnedCommandFailure)) throw failure;
|
|
expect(failure.reason).toBe("process");
|
|
expect(failure.collectionFailure).toBe(true);
|
|
expect(failure.processError).toBe(inputError);
|
|
expect(failure.cause).toHaveProperty("cause", inputError);
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("reports a premature input close as a collection failure", async () => {
|
|
const input = new Writable({
|
|
final(_callback) {
|
|
input.destroy();
|
|
},
|
|
});
|
|
const fixture = ownedInput(input);
|
|
await expect(
|
|
runOwnedCommand(
|
|
spawn,
|
|
{ timeoutMs: null, diagnosticBytes: 1024, stdin: "closed-pipe" },
|
|
{
|
|
launcher: async () => ({
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
}),
|
|
},
|
|
),
|
|
).rejects.toMatchObject({
|
|
reason: "process",
|
|
collectionFailure: true,
|
|
message: expect.stringMatching(
|
|
/stdin stream failed.*closed before writable finalization completed/i,
|
|
),
|
|
processError: {
|
|
message: "closed before writable finalization completed",
|
|
},
|
|
});
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
});
|
|
|
|
it("keeps late input errors observed through refused cleanup and the exact retry owner", async () => {
|
|
const controller = new AbortController();
|
|
const reason = { request: "abort during final cleanup" };
|
|
const inputError = new Error("late input failure");
|
|
const input = new Writable({
|
|
autoDestroy: false,
|
|
final(callback) {
|
|
callback();
|
|
fixture.child.complete();
|
|
},
|
|
});
|
|
const fixture = ownedInput(input);
|
|
let denied = true;
|
|
fixture.cleanup.mockImplementation(async () => {
|
|
if (denied) {
|
|
input.emit("error", inputError);
|
|
controller.abort(reason);
|
|
return { cleaned: false, reason: "authored input owner still held" };
|
|
}
|
|
input.emit("error", new Error("input error during retry"));
|
|
input.destroy();
|
|
return { cleaned: true, signaled: false };
|
|
});
|
|
let failure: OwnedCommandFailure | undefined;
|
|
try {
|
|
const cause: unknown = await runOwnedCommand(
|
|
spawn,
|
|
{ timeoutMs: null, diagnosticBytes: 1024, stdin: "closed-pipe" },
|
|
{
|
|
signal: controller.signal,
|
|
launcher: async () => ({
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
}),
|
|
},
|
|
).catch((cause: unknown) => cause);
|
|
if (!(cause instanceof OwnedCommandFailure)) throw cause;
|
|
failure = cause;
|
|
expect(failure).toMatchObject({
|
|
reason: "process",
|
|
collectionFailure: true,
|
|
processError: inputError,
|
|
cleanupFailure: "authored input owner still held",
|
|
});
|
|
expect(failure.cancellation?.reason).toBe(reason);
|
|
expect(failure.cleanupOwner?.launch.ownership).toBe(fixture.ownership);
|
|
expect(failure.cleanupOwner?.launch.process.stdin).toBe(input);
|
|
expect(failure.cause).toHaveProperty("cause", inputError);
|
|
denied = false;
|
|
await expect(failure.cleanupOwner?.stop()).resolves.toEqual({
|
|
status: "verified-cleanup",
|
|
});
|
|
expect(fixture.cleanup).toHaveBeenCalledTimes(2);
|
|
expect(input.destroyed).toBe(true);
|
|
expect(fixture.child.kill).not.toHaveBeenCalled();
|
|
} finally {
|
|
denied = false;
|
|
await failure?.cleanupOwner?.stop();
|
|
input.destroy();
|
|
}
|
|
});
|
|
|
|
it("keeps an explicitly selected input pipe open until process cleanup", async () => {
|
|
const stages: string[] = [];
|
|
const input = new Writable();
|
|
const ended = vi.spyOn(input, "end");
|
|
const fixture = ownedInput(input);
|
|
const cleanup = fixture.cleanup.getMockImplementation()!;
|
|
fixture.cleanup.mockImplementation(async () => {
|
|
stages.push("cleanup");
|
|
expect(input.writableEnded).toBe(false);
|
|
expect(input.writableFinished).toBe(false);
|
|
expect(input.destroyed).toBe(false);
|
|
return cleanup();
|
|
});
|
|
const snapshot = await runOwnedCommand(
|
|
spawn,
|
|
{
|
|
timeoutMs: 2_000,
|
|
diagnosticBytes: 1024,
|
|
stdin: "pipe",
|
|
observeCompleted: () => stages.push("observed"),
|
|
},
|
|
{
|
|
launcher: async (request) => {
|
|
expect(request.stdin).toBe("pipe");
|
|
setImmediate(() => {
|
|
stages.push("output");
|
|
fixture.child.stdout.write("open input output");
|
|
fixture.child.stderr.write("open input diagnostic");
|
|
fixture.child.complete();
|
|
});
|
|
return {
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
};
|
|
},
|
|
},
|
|
);
|
|
expect(snapshot).toMatchObject({
|
|
exitCode: 0,
|
|
stdout: { text: "open input output" },
|
|
stderr: { text: "open input diagnostic" },
|
|
});
|
|
expect(stages).toEqual(["output", "observed", "cleanup"]);
|
|
expect(ended).not.toHaveBeenCalled();
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
expect(input.destroyed).toBe(true);
|
|
expect(fixture.child.kill).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it.each([undefined, "pipe"] as const)(
|
|
"leaves stdin untouched without the closed-pipe contract (spawn stdin %s)",
|
|
async (stdin) => {
|
|
const input = new Writable();
|
|
const ended = vi.spyOn(input, "end");
|
|
const fixture = ownedInput(input);
|
|
await runOwnedCommand(
|
|
{ ...spawn, ...(stdin === undefined ? {} : { stdin }) },
|
|
{ timeoutMs: null, diagnosticBytes: 1024 },
|
|
{
|
|
launcher: async (request) => {
|
|
expect(request.stdin).toBe(stdin);
|
|
setImmediate(() => fixture.child.complete());
|
|
return {
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
};
|
|
},
|
|
},
|
|
);
|
|
expect(ended).not.toHaveBeenCalled();
|
|
},
|
|
);
|
|
|
|
it("reports a deadline that elapses during final cleanup as a timeout", async () => {
|
|
// Controlled time: collection never races the deadline, which elapses only
|
|
// after cleanup has demonstrably started.
|
|
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] });
|
|
try {
|
|
const fixture = ownedInput(null);
|
|
const observeCompleted = vi.fn();
|
|
const cleanupStarted = createDeferred<void>();
|
|
const releaseCleanup = createDeferred<void>();
|
|
fixture.cleanup.mockImplementation(async () => {
|
|
cleanupStarted.resolve();
|
|
await releaseCleanup.promise;
|
|
return { cleaned: true, signaled: false };
|
|
});
|
|
const pending = runOwnedCommand(
|
|
spawn,
|
|
{ timeoutMs: 1_000, diagnosticBytes: 1024, observeCompleted },
|
|
{
|
|
launcher: async () => {
|
|
setImmediate(() => {
|
|
fixture.child.stdout.write("completed output");
|
|
fixture.child.complete();
|
|
});
|
|
return {
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
};
|
|
},
|
|
},
|
|
);
|
|
const rejected = expect(pending).rejects.toMatchObject({
|
|
reason: "timeout",
|
|
cleanupFailure: null,
|
|
snapshot: { exitCode: 0, stdout: { text: "completed output" } },
|
|
});
|
|
let started = false;
|
|
void cleanupStarted.promise.then(() => (started = true));
|
|
while (!started) await vi.advanceTimersByTimeAsync(10);
|
|
expect(performance.now()).toBeLessThan(1_000);
|
|
expect(observeCompleted).toHaveBeenCalledOnce();
|
|
await vi.advanceTimersByTimeAsync(1_000);
|
|
releaseCleanup.resolve();
|
|
await rejected;
|
|
expect(fixture.cleanup).toHaveBeenCalledOnce();
|
|
} finally {
|
|
vi.useRealTimers();
|
|
}
|
|
});
|
|
|
|
it.each(["cancelled", "timeout"] as const)(
|
|
"reports a %s interruption during refused final cleanup with its retry owner",
|
|
async (interruption) => {
|
|
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] });
|
|
const controller = new AbortController();
|
|
const reason = { request: "abort during refused final cleanup" };
|
|
const fixture = ownedInput(null);
|
|
let denied = true;
|
|
const cleanupStarted = createDeferred<void>();
|
|
const releaseCleanup = createDeferred<void>();
|
|
fixture.cleanup.mockImplementation(async () => {
|
|
if (!denied) return { cleaned: true, signaled: false };
|
|
cleanupStarted.resolve();
|
|
await releaseCleanup.promise;
|
|
return { cleaned: false, reason: "process group still present" };
|
|
});
|
|
let pending: Promise<unknown> | undefined;
|
|
try {
|
|
pending = runOwnedCommand(
|
|
spawn,
|
|
{ timeoutMs: 1_000, diagnosticBytes: 1024 },
|
|
{
|
|
signal: controller.signal,
|
|
launcher: async () => {
|
|
setImmediate(() => {
|
|
fixture.child.stdout.write("completed output");
|
|
fixture.child.complete();
|
|
});
|
|
return {
|
|
process: fixture.child,
|
|
ownership: fixture.ownership,
|
|
cleanup: fixture.cleanup,
|
|
};
|
|
},
|
|
},
|
|
).catch((cause: unknown) => cause);
|
|
let started = false;
|
|
void cleanupStarted.promise.then(() => (started = true));
|
|
while (!started) await vi.advanceTimersByTimeAsync(10);
|
|
expect(performance.now()).toBeLessThan(1_000);
|
|
if (interruption === "cancelled") controller.abort(reason);
|
|
else await vi.advanceTimersByTimeAsync(1_000);
|
|
releaseCleanup.resolve();
|
|
const failure = await pending;
|
|
if (!(failure instanceof OwnedCommandFailure)) throw failure;
|
|
expect(failure).toMatchObject({
|
|
reason: interruption,
|
|
cleanupFailure: "process group still present",
|
|
snapshot: { exitCode: 0, stdout: { text: "completed output" } },
|
|
});
|
|
expect(failure.cancellation?.reason).toBe(
|
|
interruption === "cancelled" ? reason : undefined,
|
|
);
|
|
expect(failure.cleanupOwner?.launch.ownership).toBe(fixture.ownership);
|
|
denied = false;
|
|
await expect(failure.cleanupOwner?.stop()).resolves.toEqual({
|
|
status: "verified-cleanup",
|
|
});
|
|
expect(fixture.cleanup).toHaveBeenCalledTimes(2);
|
|
} finally {
|
|
denied = false;
|
|
releaseCleanup.resolve();
|
|
// Join the command even when an assertion failed before it settled;
|
|
// its deadline bounds the fake time this can take.
|
|
if (pending !== undefined) {
|
|
let settled = false;
|
|
const joined = pending.finally(() => {
|
|
settled = true;
|
|
});
|
|
for (let step = 0; !settled && step < 200; step += 1)
|
|
await vi.advanceTimersByTimeAsync(10);
|
|
const outcome = await joined;
|
|
if (outcome instanceof OwnedCommandFailure)
|
|
await outcome.cleanupOwner?.stop();
|
|
}
|
|
vi.useRealTimers();
|
|
}
|
|
},
|
|
);
|