invalidateQuery doesn't immediately refetch the invalidated query
- Dominant language
- TypeScript
- Stars
- 14.1k
- Forks
- 803
- PR merge metrics
- No merged PRs in 30d
Description
### What is the problem?
When running invalidateQuery in blitz v3.0.1 (and probably v3.0.2), the invalidated query doesn't get refetched. Trigging a manual refetch by calling the refetch method exposed by useQuery from @blitzjs/rpc
This issue serves just for documentation, so pardon me for skipping some details, I will submit a pull request that updates @tanstack/react-query to 5.90.2 which resolved the issue for us.
### Paste all your error logs here:
```
N/A
```
### Paste all relevant code snippets here:
```
const [userPlaylists, { refetch: refetchUserPlaylists }] = useSuspenseQuery(getAddableLists, undefined, {
refetchOnWindowFocus: false,
refetchOnMount: true,
refetchOnReconnect: false,
})
await invalidateQuery(getAddableLists)
```
### What are detailed steps to reproduce this?
1. Use useSuspenseQuery to fetch data (say a list of items)
2. Use another component to create a new item that would manipulate said dataset and call invalidateQuery on the first query
3. Observe the list not being updated unless you also called the refetch method
### Run `blitz -v` and paste the output here:
```
Blitz version: 2.0.0-beta.19 (global)
Blitz version: 3.0.2 (local)
macOS | darwin-arm64 | Node: v20.19.5
Package manager: npm
System:
OS: macOS 26.0.1
CPU: (10) arm64 Apple M1 Max
Memory: 1.04 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.19.5 - ~/.config/nvm/versions/node/v20.19.5/bin/node
Yarn: 1.22.22 - ~/.config/nvm/versions/node/v20.19.5/bin/yarn
npm: 10.8.2 - ~/.config/nvm/versions/node/v20.19.5/bin/npm
npmPackages:
@blitzjs/auth: Not Found
@blitzjs/next: Not Found
@blitzjs/rpc: Not Found
@prisma/client: Not Found
blitz: Not Found
next: Not Found
prisma: Not Found
react: Not Found
react-dom: Not Found
typescript: Not Found
```
### Please include below any other applicable logs and screenshots that show your problem:
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.