Skip to content

QueryClient.clear breaks existing queries #9238

Open
@farmaazon

Description

@farmaazon

Describe the bug

In vue query, after calling queryClient.clear all existing queries created with useQuery instance stop working.

An example where this is problematic: I have a query fetching information about login status and user, and many more. When logging-out, I want to remove cache of all queries, because it may contain user-related data. So I call clear after logout, but then login breaks because query for user and login status works no more.

Your minimal, reproducible example

https://github.com/farmaazon/tanstack-query-repro

Steps to reproduce

  1. clone and run the project
  2. click "invalidate" button - the timestamp is refreshed, as expected
  3. click "clear" button
  4. Now "invalidate" button stops working

Expected behavior

clear removes cached data, but existing queries are still functional and reacts for invalidation.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

I reproduced it on linux (Garuda) chrome

Tanstack Query adapter

vue-query

TanStack Query version

v5.79.2

TypeScript version

~5.8.0

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