-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): retry for infinite queries (issue #8046) #8049
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 1784c7a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
More templates
@tanstack/angular-query-experimental
@tanstack/angular-query-devtools-experimental
@tanstack/eslint-plugin-query
@tanstack/query-async-storage-persister
@tanstack/query-broadcast-client-experimental
@tanstack/query-core
@tanstack/query-devtools
@tanstack/query-persist-client-core
@tanstack/query-sync-storage-persister
@tanstack/react-query
@tanstack/react-query-next-experimental
@tanstack/react-query-devtools
@tanstack/react-query-persist-client
@tanstack/solid-query
@tanstack/solid-query-devtools
@tanstack/solid-query-persist-client
@tanstack/svelte-query
@tanstack/svelte-query-devtools
@tanstack/svelte-query-persist-client
@tanstack/vue-query-devtools
@tanstack/vue-query
commit: |
The retryer lives above the fetchFn, and it re-runs the fetchFn whenever a retry happens. Usually, the fetchFn is a thin wrapper around the actual queryFn passed by the user. However, for infinite queries, it fetches all pages in a loop. The retryer breaks out of this loop if an error occurs on e.g. the second page, and then retries by running the fetchFn - which will re-set the loop This fix hoists the currentPage counter out of the fetchFn - into the closure created by onFetch. The outer closure is created from running `query.fetch` once, so it won't be re-set between retries. The fix also re-writes the fetch loop to always take the `currentPage` into account, where it was previously treating the first page differently
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8049 +/- ##
===========================================
+ Coverage 44.51% 61.86% +17.35%
===========================================
Files 195 135 -60
Lines 7279 4683 -2596
Branches 1629 1306 -323
===========================================
- Hits 3240 2897 -343
+ Misses 3662 1544 -2118
+ Partials 377 242 -135 |
fix: retry for infinite queries
The retryer lives above the fetchFn, and it re-runs the fetchFn whenever a retry happens. Usually, the fetchFn is a thin wrapper around the actual queryFn passed by the user. However, for infinite queries, it fetches all pages in a loop.
The retryer breaks out of this loop if an error occurs on e.g. the second page, and then retries by running the fetchFn - which will re-set the loop
This fix hoists the currentPage counter out of the fetchFn - into the closure created by onFetch. The outer closure is created from running
query.fetch
once, so it won't be re-set between retries.The fix also re-writes the fetch loop to always take the
currentPage
into account, where it was previously treating the first page differentlycloses #8046