Skip to content

Conversation

@TkDodo
Copy link
Collaborator

@TkDodo TkDodo commented Jul 26, 2024

The fetchPage function has a safeguard where it only returns the current data if pageParam == null, however, this means we still stay in the loop and call getNextPageParam unnecessarily.

This can be troublesome if you set pages: Infinity on queryClient.fetchInfiniteQuery to fetch an arbitrary amount of pages until the natural end is reached by returning null/undefined from getNextPageParam, because it would never actually escape the loop

…Param returns null or undefined

The `fetchPage` function has a safeguard where it only returns the current data if pageParam == null, however, this means we still stay in the loop and call `getNextPageParam` unnecessarily.

This can be troublesome if you set `pages: Infinity` on queryClient.fetchInfiniteQuery to fetch an arbitrary amount of pages until the natural end is reached by returning null/undefined from getNextPageParam, because it would never actually escape the loop
@TkDodo TkDodo marked this pull request as ready for review July 26, 2024 08:30
@nx-cloud
Copy link

nx-cloud bot commented Jul 26, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 5056b10. 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 target

Sent with 💌 from NxCloud.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 26, 2024

commit: 5056b10

pnpm add https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@7799
pnpm add https://pkg.pr.new/@tanstack/angular-query-experimental@7799
pnpm add https://pkg.pr.new/@tanstack/eslint-plugin-query@7799
pnpm add https://pkg.pr.new/@tanstack/query-async-storage-persister@7799
pnpm add https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@7799
pnpm add https://pkg.pr.new/@tanstack/query-core@7799
pnpm add https://pkg.pr.new/@tanstack/query-devtools@7799
pnpm add https://pkg.pr.new/@tanstack/query-persist-client-core@7799
pnpm add https://pkg.pr.new/@tanstack/query-sync-storage-persister@7799
pnpm add https://pkg.pr.new/@tanstack/react-query@7799
pnpm add https://pkg.pr.new/@tanstack/react-query-devtools@7799
pnpm add https://pkg.pr.new/@tanstack/react-query-next-experimental@7799
pnpm add https://pkg.pr.new/@tanstack/react-query-persist-client@7799
pnpm add https://pkg.pr.new/@tanstack/solid-query@7799
pnpm add https://pkg.pr.new/@tanstack/solid-query-devtools@7799
pnpm add https://pkg.pr.new/@tanstack/solid-query-persist-client@7799
pnpm add https://pkg.pr.new/@tanstack/svelte-query@7799
pnpm add https://pkg.pr.new/@tanstack/svelte-query-devtools@7799
pnpm add https://pkg.pr.new/@tanstack/svelte-query-persist-client@7799
pnpm add https://pkg.pr.new/@tanstack/vue-query@7799
pnpm add https://pkg.pr.new/@tanstack/vue-query-devtools@7799

Open in Stackblitz

More templates

@TkDodo TkDodo merged commit 3ef7887 into main Jul 26, 2024
@TkDodo TkDodo deleted the feature/infinite-query-early-abort branch July 26, 2024 08:44
@mrlubos
Copy link
Contributor

mrlubos commented Jul 26, 2024

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants