Repository navigation
fix(upgrade): clear the query cache on every fixture render - #7448
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
π WalkthroughWalkthroughUpgrade tests now clear the shared React Query cache before rendering and asynchronously wait for active mutations to settle before resetting and unmounting the optimistic-update fixture. ChangesUpgrade test state isolation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
π₯ Pre-merge checks | β 5β Passed checks (5 passed)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@trpc/client
@trpc/next
@trpc/openapi
@trpc/react-query
@trpc/server
@trpc/tanstack-react-query
@trpc/upgrade
commit: |
|
Thank you, good catch! |
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
π― Changes
Fixes a CI-only failure of
transforms.test.ts > hooks optimistic-update.tsx:Expected "Posts: 1initial", Received "Posts: 2initialFoo"at the initial-render assertion β reproducible on unrelated PRs (the docs-only #7445, and #7447), always withretry x2all failing the same way.Two leaks between spec runs (the spec executes twice per test β input component and transformed snapshot β and again on CI retries), both via module-scoped state:
In-flight mutation re-populates the server after reset. The fixture's update is optimistic, so a spec run finishes (or fails) with the
createmutation still in flight.resetFixtureState()truncatesposts, then the late mutation settles and pushes'Foo'back β the next run's (or retry's) initial fetch returns2initialFoofor its wholewaitForwindow. Under CI load the settle reliably lands in that gap; on a fast local machine (whereretryis 0 anyway) it practically never does, which is why this only ever failed in CI. The spec's disposer is now async (makeAsyncResource+await using) and waits forqueryClient.isMutating() === 0before resetting.The shared
QueryClientcache outlives a run.renderAppnow clears it before mounting, so a retry can't render the previous attempt's cached data. This covers all nine fixtures using the harness; no spec renders more than once per run, so nothing relied on cache persistence.β Checklist
Summary by CodeRabbit