Skip to content

useSuspenseQueries observers count mismatch #6298

@maciej-baruch

Description

@maciej-baruch

Describe the bug

When the amount of queries in useSuspenseQueries increases, the new queries resolution/suspense is split into two batches.
The first batch takes care of newQueries.slice(0, previousQueries.length) and stops the suspense, causing the rest of the queries to be still pending (and have undefined data) before the second batch (rest of the newQueries) kicks in.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/friendly-jang-gjp9p8

Steps to reproduce

  1. Click the button.
  2. Observe the lifecycle of queries in the console.

Expected behavior

As a user, I would expect newQueries to be resolved all at once in a single suspense.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Platform agnostic.

Tanstack Query adapter

react-query

TanStack Query version

5.4.3

TypeScript version

5.2.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions