Skip to content

Suspended query continues to suspend until queryFn promise is fullfiled even when the query data is updated #10924

@MrBr

Description

@MrBr

Describe the bug

Suspense query keeps suspending when data exists. Originally, I noticed the problem in streamedQuery in combination with useSuspenseQuery. The issue reflects in such way that suspense query keeps suspending even after the first stream chunk is received.

I'd like to note that the aforementioned behaviour could be useful in some cases, but that's a separate issue I guess.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/cranky-benz-xvt2n2

Steps to reproduce

  1. Go to https://codesandbox.io/p/sandbox/cranky-benz-xvt2n2?file=%2Fsrc%2FApp.js
  2. Click the button
  3. Loading text remains even though the query client has the data for the key

Expected behavior

I'd expect data to show.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • Every platform

Tanstack Query adapter

None

TanStack Query version

5.101.0

TypeScript version

No response

Additional context

An idea about solution. Maybe wrapping suspense queryFn result with additional promise could provide more control?

Not sure what is the right way to handle the ongoing promise when the data is set programatically? Should this behaviour be controlled by user through options?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions