Skip to content

fix: drop callCount from dedup tests — still flaky after #419#421

Merged
BYK merged 1 commit into
mainfrom
fix/flaky-dedup-test
May 20, 2026
Merged

fix: drop callCount from dedup tests — still flaky after #419#421
BYK merged 1 commit into
mainfrom
fix/flaky-dedup-test

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 20, 2026

Summary

Follow-up to #419. The delta-based callCount fix was still flaky in CI (run): Expected: 1, Received: 2.

Root Cause

await Promise.all() yields to the event loop. During that yield, other test files' code can call fetch() against our globalThis.fetch mock, incrementing callCount. This happens even with the delta-based counting from #419 because the counter is incremented between the reset and the assertion.

Fix

  • Dedup tests: Remove callCount entirely. Promise identity (expect(pa).toBe(pb)) is the correct and sufficient assertion — it verifies the inflight promise is shared across concurrent callers without any exposure to cross-test globals. Captured synchronously, no event-loop yield.
  • Cache test: Relax to toBeGreaterThanOrEqual(1) for the first fetch (pollution can inflate during await yields), keep strict delta === 0 for the cache hit.

…ss-test fetch pollution

The delta-based callCount fix in #419 was insufficient: await
Promise.all() yields to the event loop, allowing other test files to
call fetch() against our mock during the microtask resolution window.
This inflated callCount from 1 to 2 intermittently in CI.

Changes:
- Remove callCount entirely from the two dedup tests. Promise identity
  (expect(pa).toBe(pb)) is the correct and sufficient assertion — it
  verifies the inflight promise is shared without any exposure to
  cross-test globals.
- Relax the 'caches results' test to use toBeGreaterThanOrEqual(1)
  for the first fetch (cross-test pollution can inflate during await
  yields) while keeping the strict delta=0 check for the cache hit.
@BYK BYK self-assigned this May 20, 2026
@BYK BYK merged commit a509c1b into main May 20, 2026
7 checks passed
@BYK BYK deleted the fix/flaky-dedup-test branch May 20, 2026 10:10
This was referenced May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant