test(react-query-persist-client/PersistQueryClientProvider): replace 'await sleep' with 'sleep().then()' pattern in restoreClient and add additional timer advance for refetch verification
π― Changes
β Checklist
- [x] I have followed the steps in the Contributing guide.
- [x] I have tested this code locally with
pnpm run test:pr.
π Release Impact
- [ ] This change affects published code, and I have generated a changeset.
- [x] This change is docs/CI/dev-only (no release).
Summary by CodeRabbit
-
Tests
- Enhanced test coverage to verify that persisted data maintains stability across extended delays.
-
Bug Fixes
- Refined error handling timing in the persist client to ensure errors are thrown consistently after a short delay, improving reliability of error scenarios.
βοΈ Tip: You can customize this high-level summary in your review settings.
β οΈ No Changeset found
Latest commit: fb4071eaaff0fb0e478e69189b872873844b1d01
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Walkthrough
Test updates in PersistQueryClientProvider.test.tsx: query function implementations were rewritten to use async/await (previously used promise chains), and tests advance timers an additional 11ms to assert hydration state remains stable after the longer simulated delay.
Changes
| Cohort / File(s) | Summary |
|---|---|
PersistQueryClientProvider Tests packages/react-query-persist-client/src/__tests__/PersistQueryClientProvider.test.tsx |
Rewrote queryFn implementations from promise .then() chains to async/await with an await sleep(10) before producing values; added an extra 11ms timer advance in tests and updated assertions to verify hydration state remains stable after the extended delay. |
Estimated code review effort
π― 2 (Simple) | β±οΈ ~10 minutes
- Review the rewritten queryFn logic to ensure behavior matches prior promise-chain timing.
- Verify the additional 11ms timer advance doesn't introduce flakiness in related timing-sensitive tests.
Possibly related PRs
- TanStack/query#9859 β Modifies the same test file and adjusts async/delay handling patterns; likely related to timing/control-flow in tests.
Suggested reviewers
- manudeli
Poem
π I waited ten, then yielded the prize,
Awaited the tick while timers ran wise.
Eleven more beats to prove what we knew β
Hydration held steady, the test passed true. π₯
Pre-merge checks and finishing touches
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
β Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | β Passed | The title accurately describes the main changes: converting callbacks to async/await and adding delayed assertions for test verification in PersistQueryClientProvider tests. |
| Description check | β Passed | The description follows the template structure with completed checklist items and correctly identifies the change as dev-only with no release impact, though the 'Changes' section lacks detail. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Comment @coderabbitai help to get the list of available commands and usage tips.
View your CI Pipeline Execution β for commit fb4071eaaff0fb0e478e69189b872873844b1d01
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=test:sherif,test:knip,tes... |
β Succeeded | 50s | View β |
nx run-many --target=build --exclude=examples/*... |
β Succeeded | 1s | View β |
βοΈ Nx Cloud last updated this comment at 2025-12-19 01:56:11 UTC
More templates
- @tanstack/query-example-react-algolia
- @tanstack/query-example-react-auto-refetching
- @tanstack/query-example-react-basic
- @tanstack/query-example-react-basic-graphql-request
- @tanstack/query-example-chat
- @tanstack/query-example-react-default-query-function
- @tanstack/query-example-react-devtools-panel
- @tanstack/query-example-eslint-legacy
- @tanstack/query-example-react-infinite-query-with-max-pages
- @tanstack/query-example-react-load-more-infinite-scroll
- @tanstack/query-example-react-nextjs
- @tanstack/query-example-react-nextjs-app-prefetching
- @tanstack/query-example-nextjs-suspense-streaming
- @tanstack/query-example-react-offline
- @tanstack/query-example-react-optimistic-updates-cache
- @tanstack/query-example-react-optimistic-updates-ui
- @tanstack/query-example-react-pagination
- @tanstack/query-example-react-playground
- @tanstack/query-example-react-prefetching
- @tanstack/query-example-react-react-native
- @tanstack/query-example-react-router
- @tanstack/query-example-react-rick-morty
- @tanstack/query-example-react-shadow-dom
- @tanstack/query-example-react-simple
- @tanstack/query-example-react-star-wars
- @tanstack/query-example-react-suspense
- @tanstack/query-example-angular-auto-refetching
- @tanstack/query-example-angular-basic
- @tanstack/query-example-angular-basic-persister
- @tanstack/query-example-angular-devtools-panel
- @tanstack/query-example-angular-infinite-query-with-max-pages
- @tanstack/query-example-angular-optimistic-updates
- @tanstack/query-example-angular-pagination
- @tanstack/query-example-angular-query-options-from-a-service
- @tanstack/query-example-angular-router
- @tanstack/query-example-angular-rxjs
- @tanstack/query-example-angular-simple
- @tanstack/query-example-solid-astro
- @tanstack/query-example-solid-basic
- @tanstack/query-example-solid-basic-graphql-request
- @tanstack/query-example-solid-default-query-function
- @tanstack/query-example-solid-simple
- @tanstack/query-example-solid-start-streaming
- @tanstack/query-example-svelte-auto-refetching
- @tanstack/query-example-svelte-basic
- @tanstack/query-example-svelte-load-more-infinite-scroll
- @tanstack/query-example-svelte-optimistic-updates
- @tanstack/query-example-svelte-playground
- @tanstack/query-example-svelte-simple
- @tanstack/query-example-svelte-ssr
- @tanstack/query-example-svelte-star-wars
- @tanstack/query-example-vue-2.6-basic
- @tanstack/query-example-vue-2.7-basic
- @tanstack/query-example-vue-basic
- @tanstack/query-example-vue-dependent-queries
- @tanstack/query-example-vue-nuxt3
- @tanstack/query-example-vue-persister
- @tanstack/query-example-vue-simple
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9901
@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9901
@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9901
@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9901
@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@9901
@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@9901
@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9901
@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9901
@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@9901
@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@9901
@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9901
@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9901
@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@9901
@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9901
@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9901
@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@9901
@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9901
@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9901
@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@9901
@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9901
commit: fb4071e
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 100.00%. Comparing base (f15b7fc) to head (fb4071e).
Additional details and impacted files
@@ Coverage Diff @@
## main #9901 +/- ##
============================================
+ Coverage 45.89% 100.00% +54.10%
============================================
Files 200 1 -199
Lines 8437 18 -8419
Branches 1943 2 -1941
============================================
- Hits 3872 18 -3854
+ Misses 4116 0 -4116
+ Partials 449 0 -449
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.