Skip to content

Inactive query is not garbage collected when a useSuspenseQuery is made inactive while in fetching state #8159

@cirex-web

Description

@cirex-web

Describe the bug

I set gcTime to 1000, so we should expect inactive queries to disappear from the cache pretty quickly. This does not happen when we inactivate the query while it is still being fetched.

Sequence.02_1.mp4

useQuery doesn't have this bug, however.

Your minimal, reproducible example

https://github.com/cirex-web/tanstack-gc-bug

Steps to reproduce

See video above

Expected behavior

I expected the query cached value to be deleted within 1s of being inactive.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

OS - macOS
Browser - Chrome
Browser Version - 129.0.6668.71

Tanstack Query adapter

react-query

TanStack Query version

v5.59.8

TypeScript version

v5.6.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions