Skip to content
Source
Sign inSign up
TanStack/query

Solid: `refetchOnMount: false` causes suspenses when mutating #9883

Send to my agent
Closedteidesu(GitHub profile, opens in a new tab) opened this issue 2 comments

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 useQuery that 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

  1. open repro
  2. open devtools
  3. click "mutate"
  4. notice how the dom tree below the suspense is re-added, and Suspense triggered is logged
  5. 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

  1. TkDodo added labelspackage: solid-query

  2. 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:

    1. Modified the resource resolution logic to resolve immediately when data is available, regardless of isLoading state
    2. 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.

Sign in to join this conversation.