Skip to content

Commit 0a23408

Browse files
test(poe): poll the timeout instead of sleeping in the abort-ordering test
Upstream adds a no-restricted-globals rule for setTimeout under api/**/__tests__/**/*.spec.ts ("Poll with vi.waitFor on the observable condition"), and the merged-ref lint job enforces it, so this branch's fixed 40 ms sleep in "keeps TimeoutError when the timeout fires before a later caller abort and late result" fails compile. The observable condition is available: the merged signal aborting IS the 20 ms per-request timeout firing, so the SDK double now polls that (the house pattern, e.g. request-config-builder.spec.ts:408) before the caller aborts and the result settles late. Ordering is pinned rather than timed. api/providers/__tests__/poe.spec.ts: 43/43 green; src tsc --noEmit and eslint --max-warnings=0 clean; no suppression added.
1 parent 27b0fea commit 0a23408

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/api/providers/__tests__/poe.spec.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,10 @@ describe("PoeHandler", () => {
812812
let mergedSignal: AbortSignal | undefined
813813
mockGenerateText.mockImplementationOnce(async (args: { abortSignal?: AbortSignal }) => {
814814
mergedSignal = args.abortSignal
815-
// Let the 20 ms timeout fire first, then abort the caller, then settle late.
816-
await new Promise<void>((resolve) => setTimeout(resolve, 40))
815+
// Poll the observable condition rather than sleeping a fixed 40 ms: the merged signal aborting IS
816+
// the 20 ms per-request timeout firing. Only then does the caller abort and the SDK settle
817+
// late, so the ordering the test is about is pinned instead of timed.
818+
await vi.waitFor(() => expect(mergedSignal?.aborted).toBe(true))
817819
callerController.abort()
818820
return { text: "late result" }
819821
})

0 commit comments

Comments
 (0)