Description
Describe the bug
The Vue implementation of QueryClient.invalidateQueries
does not invalidate queries "immediately", as described in the documentation.
Your minimal, reproducible example
https://codesandbox.io/p/devbox/vue-query-query-invalidation-w2kn9y
Steps to reproduce
Run the CodeSandbox; the rendered page shows the difference in behavior between the Vue QueryClient and the base implementation (the latter seems more consistent with the documentation).
Expected behavior
The documentation for QueryClient.invalidateQueries says that "By default, all matching queries are immediately marked as invalid and active queries are refetched in the background." I understand this to mean that, after calling the function, matched queries should be seen to be invalidated, even if the function's returned Promise
was not awaited. This is the case when using the base QueryClient
of @tanstack/query-core
.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Not operating-system specific
- Browser: Not browser-specific
- Browser version: Not browser-version specific
Tanstack Query adapter
vue-query
TanStack Query version
v5.51.0
TypeScript version
No response
Additional context
A workaround I'm using is to override invalidateQueries
with an implementation that performs the invalidations immediately, deferring only the query refetches (as required to fix #6414).