Skip to content

test(cloudflare): Add headroom for wrangler cold-start in integration tests#22083

Merged
mydea merged 1 commit into
developfrom
test/fix-flaky-cloudflare-timeouts
Jul 9, 2026
Merged

test(cloudflare): Add headroom for wrangler cold-start in integration tests#22083
mydea merged 1 commit into
developfrom
test/fix-flaky-cloudflare-timeouts

Conversation

@mydea

@mydea mydea commented Jul 8, 2026

Copy link
Copy Markdown
Member

The Cloudflare integration tests are a recurring source of flaky-CI reports across several suites.

Root cause

Every test spawns its own wrangler dev (cold workerd boot), makes a request, and waits for envelopes to be delivered to the mock server. Two ceilings are tight for how slow and variable wrangler cold-start is on a loaded CI runner:

  • The runner has no internal timeout, so it relies entirely on Vitest's testTimeout (was 30s). Cold-start + async work (Durable Objects, Workflows) + envelope delivery must all fit in that budget.
  • fetchWithRetry — which the runner already uses to paper over wrangler's "reports Ready before it can serve" race — only tolerated a ~2s window.

Locally these tests finish in <5s and I could not reproduce a failure across 80+ runs, which is consistent with a low-rate, load-dependent cold-start stall rather than a logic bug.

Fix

  • Raise testTimeout 30s → 60s.
  • Raise the fetchWithRetry budget 10 → 25 attempts (~2s → ~5s).

Both are pure ceilings — tests complete as soon as the worker serves and envelopes arrive, so there's no happy-path cost and no assertion changes.

Since I couldn't reproduce locally or retrieve the (expired) CI logs, these target the two documented/architectural races of the spawn-wrangler-per-test setup. If a specific suite keeps flaking afterwards with a fast, deterministic failure (e.g. a 500 response or a wrong assertion), that would indicate a genuine intermittent bug in that suite needing its own investigation.

Fixes #22047
Fixes #21916
Fixes #21831
Fixes #21665

🤖 Generated with Claude Code

… tests

The Cloudflare integration tests flake on CI. Each test spawns its own
`wrangler dev` (cold workerd boot), makes a request, and waits for envelopes to
be delivered to the mock server. The runner has no internal timeout, so it relies
entirely on Vitest's `testTimeout`; and `fetchWithRetry` only tolerates a ~2s
"ready-but-not-serving" window. Both are tight given how slow and variable
wrangler cold-start is on a loaded CI runner (locally these tests finish in
<5s, but CI cold-start can stall for much longer).

- Raise `testTimeout` from 30s to 60s.
- Raise the `fetchWithRetry` budget from 10 to 25 attempts (~2s -> ~5s) to cover
  a longer ready-but-not-serving window.

Both are pure ceilings with no happy-path cost — tests still complete as soon as
the worker serves and envelopes arrive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea mydea requested a review from a team as a code owner July 8, 2026 11:36
@mydea mydea requested review from JPeer264 and andreiborza and removed request for a team July 8, 2026 11:36
@mydea mydea merged commit ff69234 into develop Jul 9, 2026
48 checks passed
@mydea mydea deleted the test/fix-flaky-cloudflare-timeouts branch July 9, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment