Skip to content

useInfiniteQuery + experimental_prefetchInRender never finishes loading after error boundary reset #9939

@OliverJAsh

Description

@OliverJAsh

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.

Screen.Recording.2025-12-02.at.16.13.18.mov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions