From 97cb10714e7bb7b5b6e5b0bbdbd3d4a1fa113385 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 15 Aug 2026 08:44:43 -0700 Subject: [PATCH] test: fix variants-retry-after HTTP-date flake (TODOS P2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit toUTCString() truncates to whole seconds, so a +3000ms Retry-After date could mean an effective wait of ~2001ms — flaking against the 2500ms assertion floor ~1-2 in 9 runs under suite load. +4000ms puts the truncation floor at 3001ms with the assertion floor safely below it. Pulled forward from U4 because the free-tests lane is now a required check and this flake would randomly block PRs. Co-Authored-By: Claude Fable 5 --- design/test/variants-retry-after.test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/design/test/variants-retry-after.test.ts b/design/test/variants-retry-after.test.ts index 3740d69a4..801c3e944 100644 --- a/design/test/variants-retry-after.test.ts +++ b/design/test/variants-retry-after.test.ts @@ -78,7 +78,12 @@ describe("generateVariant Retry-After handling", () => { test("HTTP-date: honors a future date with no extra leading exponential", async () => { const calls: CallRecord[] = []; - const future = new Date(Date.now() + 3000).toUTCString(); + // toUTCString() truncates to whole seconds: a +3000ms date could mean an + // effective wait as low as ~2001ms, which flaked against a 2500ms floor + // under suite load (~1-2 in 9 runs — the TODOS P2 flake). +4000ms makes + // the truncation floor 3001ms; the assertion floor sits safely below it + // and the ceiling stays wide enough for a loaded scheduler. + const future = new Date(Date.now() + 4000).toUTCString(); const fetchFn = makeStubFetch([rateLimited(future), successResponse()], calls); const result = await generateVariant( @@ -88,8 +93,8 @@ describe("generateVariant Retry-After handling", () => { expect(result.success).toBe(true); expect(calls.length).toBe(2); const gap = calls[1].ts - calls[0].ts; - expect(gap).toBeGreaterThanOrEqual(2500); - expect(gap).toBeLessThan(4500); + expect(gap).toBeGreaterThanOrEqual(2900); + expect(gap).toBeLessThan(5500); }); test("invalid Retry-After (alphanumeric): falls through to exponential", async () => {