Repository navigation
test(swr): make remote mutation race deterministic - #752
Merged
Merged
Conversation
9 of 10 tasks
leonidaz
marked this pull request as ready for review
August 13, 2026 20:38
trueadm
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
foobefore the mutation exists, so the test no longer exercises the race it claims to cover.Changes
Validation
pnpm format:check— not run; scoped formatting check passed for all seven changed files.pnpm typecheck— not run; no TypeScript or public API changed.pnpm test— not run; validation was kept SWR-scoped as requested.node --test scripts/react-parity/swr-upstream-timer-gate.test.mjs: 1 passed.pnpm --filter @octanejs/swr upstream:verify: passed (367 identities accounted for).pnpm vitest run --project swr --project swr-differential: 11 files and 39 tests passed.node scripts/react-parity/check.mjs --validate-only: passed.pnpm syncRisk / follow-ups
Provenance
agent-authored)Note
Low Risk
Changes are limited to audit/test harness and parity metadata; vendored upstream bytes and SWR runtime are untouched.
Overview
Fixes flaky CI on the pinned byte-exact SWR 2.4.2 pristine Jest suite by making one upstream remote-mutation race case deterministic without changing vendored tests or assertions.
The pristine Jest config now maps
@testing-library/reactto a narrow harness that only activates foruseSWR - remote mutation should prevent race conditions with useSWR. On render, it usesholdFirstTimeoutto defer the first 10 mssetTimeout(the initial request completion); on click, it releases that timer so the mutation starts before the request finishes—preserving the overlap the upstream test assumes but that loaded runners can violate.Adds
upstream-timer-gate.cjs, a Node contract test, parity manifest hashes/notes, and UPSTREAM.md documentation for the harness.Reviewed by Cursor Bugbot for commit f444bd4. Bugbot is set up for automated code reviews on this repo. Configure here.