query icon indicating copy to clipboard operation
query copied to clipboard

`useInfiniteQuery` + `experimental_prefetchInRender` never finishes loading after error boundary reset

Open OliverJAsh opened this issue 2 months ago • 1 comments

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

  1. Click "Show Projects" (fetches first page which results in an error)
  2. 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

OliverJAsh avatar Dec 02 '25 16:12 OliverJAsh

@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!

TheGlaZer avatar Dec 08 '25 16:12 TheGlaZer