Skip to content

Commit 19dfdad

Browse files
committed
test(agents): stabilize non-finite run drain timeout
1 parent 44507fc commit 19dfdad

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

src/agents/run-wait.test.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,21 @@ describe("waitForAgentRunsToDrain", () => {
478478
callGatewayMock.mockResolvedValue({ status: "ok" });
479479
let activeRunIds = ["run-1"];
480480

481-
const result = await waitForAgentRunsToDrain({
482-
timeoutMs: Number.NaN,
483-
getPendingRunIds: () => {
484-
const current = activeRunIds;
485-
activeRunIds = [];
486-
return current;
487-
},
488-
});
481+
vi.useFakeTimers();
482+
vi.setSystemTime(new Date("2026-01-01T00:00:00.000Z"));
483+
let result: Awaited<ReturnType<typeof waitForAgentRunsToDrain>>;
484+
try {
485+
result = await waitForAgentRunsToDrain({
486+
timeoutMs: Number.NaN,
487+
getPendingRunIds: () => {
488+
const current = activeRunIds;
489+
activeRunIds = [];
490+
return current;
491+
},
492+
});
493+
} finally {
494+
vi.useRealTimers();
495+
}
489496

490497
expect(result.timedOut).toBe(false);
491498
expect(Number.isFinite(result.deadlineAtMs)).toBe(true);

0 commit comments

Comments
 (0)