query
query copied to clipboard
`useInfiniteQuery` + `experimental_prefetchInRender` never finishes loading after error boundary reset
Describe the bug
When an error occurs in useInfiniteQuery + experimental_prefetchInRender and the error boundary is subsequently reset, the data never finishes loading.
It does work correctly if I switch to using useSuspenseInfiniteQuery. I would expect both of these hooks to behave the same.
https://github.com/user-attachments/assets/7a19034d-c29f-4c46-9c52-7f6f8d1c2b04
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-s4bncekk?file=src%2Fcomponents%2FProjects.tsx&preset=node
Steps to reproduce
- Click "Show Projects" (fetches first page which results in an error)
- Click "Try again"
// ❌ When error boundary is reset, it never finishes loading.
const { promise } = useInfiniteQuery({
queryKey: ['projects'],
queryFn: fetchProjects,
experimental_prefetchInRender: true,
});
const data = React.use(promise);
// // ✅ When error boundary is reset, it does finish loading.
// const { data } = useSuspenseInfiniteQuery({
// queryKey: ['projects'],
// queryFn: fetchProjects,
// experimental_prefetchInRender: true,
// });
Expected behavior
- I would expect the data to finish loading.
- I would expect both of these hooks to behave the same.
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
N/A
Tanstack Query adapter
None
TanStack Query version
5.90.11
TypeScript version
No response
Additional context
No response
@TkDodo I'd like to contribute and work on this issue. Could you please confirm whether this issue is still relevant and needs a fix? Thanks!