Skip to content
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

Merged
merged 4 commits into from
Sep 12, 2024

Commits on Sep 12, 2024

  1. Configuration menu
    Copy the full SHA
    c363592 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4f568ad View commit details
    Browse the repository at this point in the history
  3. 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
    TkDodo committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    03fa7e1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1784c7a View commit details
    Browse the repository at this point in the history