SIGN IN SIGN UP
TanStack / query UNCLAIMED

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.

0 0 0 TypeScript

fix(core): retry for infinite queries (issue #8046) (#8049)

* Add reproduction test for infinite loop retries (issue #8046)

* ci: apply automated fixes

* 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 differently

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
E
EL AYADI Mohamed committed
a106d631af2a1dd1d7a9224875c9e73ae75d5675
Parent: d29c37a
Committed by GitHub <noreply@github.com> on 9/12/2024, 2:18:23 PM