Skip to content

Incorrect isFetching state when using the PersistQueryClient #8531

Closed as not planned
@JohannesByle

Description

Describe the bug

When using the PersistQueryClient on first load, before the data has been hydrated, isFetching is false while isPending true. This may be expected behavior, but seems to contradict the docs which state: "fetching: Is true whenever the queryFn is executing, which includes initial pending as well as background refetches."

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/elated-pasteur-9srm74

Steps to reproduce

In the CodeSandbox I have a dummy restoreClient which just awaits a long setTimeout, and single useQuery. I display the isPending and isFetching variables which are true and false respectively on first load.

Expected behavior

I expect isFetching to be true when isPending is true on first load.

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

OS: [Windows]
Browser: [Chrome]

Tanstack Query adapter

react-query

TanStack Query version

5.62.3

TypeScript version

5.7.2

Additional context

No response

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