Solid: `refetchOnMount: false` causes suspenses when mutating
Describe the bug
this is a very weird bug that was a pain to debug due to that
i've been able to narrow it down to this:
- given a QueryClient with
refetchOnMount: false - and a
useQuerythat already has some data cached - the first mutation will cause a suspense to trigger
Your minimal, reproducible example
https://stackblitz.com/edit/tanstack-query-qltuvrie?file=src%2Findex.tsx
Steps to reproduce
- open repro
- open devtools
- click "mutate"
- notice how the dom tree below the suspense is re-added, and
Suspense triggeredis logged - click a few more times, notice how the suspense is not triggered
Expected behavior
Suspense is not triggered
How often does this bug happen?
Every time
Screenshots or Videos
https://github.com/user-attachments/assets/9098b06f-452b-4cbf-bab1-60d8515f2126
Platform
- OS: macOS
- Browser: Chrome 142
- Version: solid-query 5.90.13, solid 1.9.10
Tanstack Query adapter
solid-query
TanStack Query version
5.90.13
TypeScript version
5.8.3
Additional context
No response
I've submitted a fix for this issue: https://github.com/TanStack/query/pull/10053 The problem was that the Proxy handler in useBaseQuery was calling queryResource() even when cached data was available, which triggered Suspense unnecessarily.
Changes:
- Modified the resource resolution logic to resolve immediately when data is available, regardless of isLoading state
- Updated the Proxy handler to return cached data directly when isFetching is false, avoiding unnecessary resource access
I've also added a test case that verifies Suspense is never triggered (including initial render) when using refetchOnMount: false with pre-cached data.
Closing as duplicate