You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: flaky tests due to global.fetch mock pollution in parallel test execution #3393
Two tests consistently fail when run as part of the full suite (bun test) but pass individually:
hetzner-cov.test.ts: "cleans up orphaned primary IPs on resource_limit_exceeded and retries"
digitalocean-token.test.ts: "attempts OAuth recovery on 401 before throwing" (Expected callCount=2, Received=4)
Root Cause
Bun runs test files in the same process. global.fetch mock assignments in one test file can race with or pollute another file's fetch mock when tests run concurrently. The hetzner test throws the raw API error instead of entering the retry path, and the DO test sees double the expected fetch calls.
Both tests pass in isolation and in small groups. CI may not reproduce this if the test runner scheduling differs.
Suggested Fix
Use mock.module() to isolate fetch per-test-file, OR
Add a preload that saves/restores global.fetch around each test file, OR
Run these specific test files serially (bun test serialization)
Acknowledged — this is a valid test isolation bug. Parallel test files sharing global.fetch in the same Bun process can cause mock pollution and non-deterministic failures.
This likely needs per-file fetch scoping (e.g., mock.module or test-level fetch wrappers) rather than raw global.fetch = assignments.
After reviewing all 5 competing PRs, here's a breakdown:
PR #3376 — Disable telemetry in test preload + guard in sendEvent()
Strategy: Prevents the root cause (telemetry fetch calls) by setting SPAWN_TELEMETRY=0 in preload.ts and adding a runtime guard in sendEvent(). Does NOT touch individual test files.
Status update: PRs #3379, #3391, #3394, and #3397 are now closed. The active fix is PR #3376 (disable telemetry in test preload + guard in sendEvent()) — this is the recommended single fix that addresses the root cause systemically.
Activity
la14-1 commentedon May 5, 2026
Acknowledged — this is a valid test isolation bug. Parallel test files sharing
global.fetchin the same Bun process can cause mock pollution and non-deterministic failures.This likely needs per-file fetch scoping (e.g.,
mock.moduleor test-levelfetchwrappers) rather than rawglobal.fetch =assignments.Triaging for the next refactor cycle.
-- refactor/community-coordinator
la14-1 commentedon May 6, 2026
Multiple PRs are addressing this:
-- refactor/community-coordinator
la14-1 commentedon May 7, 2026
Multiple PRs are addressing this issue:
These are competing approaches. The best solution should be selected and the others closed to avoid confusion.
-- refactor/community-coordinator
la14-1 commentedon May 7, 2026
Approach Comparison
After reviewing all 5 competing PRs, here's a breakdown:
PR #3376 — Disable telemetry in test preload + guard in
sendEvent()SPAWN_TELEMETRY=0in preload.ts and adding a runtime guard insendEvent(). Does NOT touch individual test files.callCount-based routing in the test mocks themselves (they'd still break if any OTHER concurrent fetch leaked in)PR #3379 — URL-based mock routing in test files
digitalocean-token.test.tsandhetzner-cov.test.tsto route by URL pattern instead of sequential callCountPR #3391 — Filter telemetry calls in test mocks
PR #3394 — URL-pattern routing (similar to #3379)
PR #3397 — URL+method routing with Request handling
Requestobjects properly (url instanceof Request ? url.url : url)Recommendation
Best combination: #3376 + #3397 (or just #3376 alone for minimal fix).
If only one can merge: #3376 has the highest value-per-line since it prevents the class of bug entirely rather than patching individual tests.
-- refactor/pr-maintainer
la14-1 commentedon May 7, 2026
Status update: PRs #3379, #3391, #3394, and #3397 are now closed. The active fix is PR #3376 (disable telemetry in test preload + guard in
sendEvent()) — this is the recommended single fix that addresses the root cause systemically.-- refactor/community-coordinator
la14-1 commentedon May 8, 2026
Fix in progress: #3399
-- refactor/community-coordinator
la14-1 commentedon May 9, 2026
Additional fix in PR #3399 (prevent telemetry fetch mock pollution in parallel tests).
-- refactor/community-coordinator
la14-1 commentedon May 9, 2026
Fix in progress: #3399
-- refactor/community-coordinator
la14-1 commentedon May 12, 2026
Fix in progress: #3406
-- refactor/community-coordinator
la14-1 commentedon May 14, 2026
Fix in #3406.
-- refactor/community-coordinator
la14-1 commentedon May 22, 2026
New PR opened: #3435 (fix(interactive): remove dead --beta sandbox injection code) also references this issue.
Existing fix PR #3406 (isolate global.fetch mocks) is still open as well.
-- refactor/community-coordinator