infiniteQuery throws "getNextPageParam is not a function" when 2+ stale pages are cached
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
The failing path is the infiniteQuery and fetchInfiniteQuery handling in query-core when stale pages are already cached, and the error surfaces as options.getNextPageParam is not a function. Start by reproducing with the stackblitz example or a small test that seeds two pages with setQueryData, then trace where getNextPageParam is read during the refetch of existing pages. Done means the call either works without the callback or the types require it, with a regression test covering the stale multi-page case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Hey :)
I ran into this while testing query-core.
I can call queryClient.infiniteQuery without getNextPageParam as long as I don't pass pages. TypeScript is fine with it, and it works on an empty cache.
But if the same key already has 2 or more pages cached and they're stale, the exact same call throws:
TypeError: options.getNextPageParam is not a function
Same with fetchInfiniteQuery. prefetchInfiniteQuery doesn't throw, but it leaves the query in an error state.
So the same call works or crashes depending on what's already in the cache.
Thanks!
Your minimal, reproducible example
https://stackblitz.com/github/a-botermans/tanstack-query-infinite-repro
Steps to reproduce
- Have 2 pages in the cache for a key. The demo uses
setQueryData, but loading them withuseInfiniteQuery+fetchNextPagegives the same result. - Let them go stale. The default
staleTime: 0is enough. - Call
infiniteQueryon the same key, withoutpagesand withoutgetNextPageParam:
queryClient.setQueryData(['pages'], {
pages: ['page 0', 'page 1'],
pageParams: [0, 1],
})
await queryClient.infiniteQuery({
queryKey: ['pages'],
queryFn: ({ pageParam }) => `page ${pageParam}`,
initialPageParam: 0,
})
It refetches the first page fine, then throws when it needs the param for page 2.
Expected behavior
No internal TypeError for a call the types accept. Either it works without the callback, or the types should ask for it.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Not platform specific. Reproduced on Node 26 and in Chromium.
Tanstack Query adapter
vanilla
TanStack Query version
v5.107.1
TypeScript version
v5.6.3
Additional context
- The same steps work on 4.44.0 and fail on 5.0.0, so it looks like it came in with v5.
- With the default retries in the browser, the TypeError gets retried like a network error. The call hangs for about 7 seconds before it rejects.
- Workaround: pass
getNextPageParamin the call too. Then it refetches all the pages.
- Ngôn ngữ chính
- TypeScript
- Star
- 50.6k
- Fork
- 4.2k
- Merge trung bình
- 8 giờ 37 phút
- Pull request đã merge (30 ngày)
- 450
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/query
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
TanStack/query#12466 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
solid-query: STRICT_READ_UNTRACKED on Solid 2 — client()/options() read in component body (useMutation, useBaseQuery)Có thể làm lại được @LeonxLJX đã nhận 74 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
TanStack/query#11358 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Infinite render loop when select maps keepPreviousData to undefined in v5.105.2+Có thể đã có người làm @mooxl đã nhận 6 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
TanStack/query#12574 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/query
Issue tương tự
-
bot:ai-assisted component:platform-js status:untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
midnightntwrk/platform-js#38 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ranxianglei/billion-context#7068 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
vendor: bump whisper.cpp past 6a8addd — the current pin aborts the app on a failed Metal initĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
mybigday/whisper.rn#348 ·
-
enhancement severity:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Battle-Cattle/BCUK-Bot-4#1075 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
ilan-pinto/roaring-lions#1552 ·
Maintainer thường phản hồi trong vòng 1 ngày