* fix(query-core): resolve suspense when query data is set programmatically
When useSuspenseQuery is used and setQueryData populates the cache
while a fetch is in-flight, the suspense boundary stays stuck on the
original fetch promise. This prevents streamedQuery and manual cache
updates from releasing suspense.
Modify fetchOptimistic in queryObserver to use Promise.race between
the fetch promise and a cache subscriber that listens for 'updated'
events. When data appears in the cache via setQueryData or a streamed
chunk, the race resolves immediately without aborting the fetch.
This allows the suspense boundary to release and show the available
data while the fetch continues in the background.
Closes#10924
Co-authored-by: atlarix-agent <agent@atlarix.dev>
* chore: add changeset for suspense setQueryData fix
Co-authored-by: atlarix-agent <agent@atlarix.dev>
* fix(query-core): prevent subscription leak in fetchOptimistic on fetch rejection
unsubscribe() was only called in the .then() success path. If
query.fetch() rejected before the cache subscriber resolved the race,
the subscription leaked — staying registered on QueryCache indefinitely
and checking a stale queryHash on every 'updated' event.
Use .finally() to ensure unsubscribe() runs on both success and
rejection, preserving the original promise type through the chain.
Co-authored-by: atlarix-agent <agent@atlarix.dev>
* fix(query-core): settle floating promise in fetchOptimistic and add undefined test
- Resolve the subscriber promise when fetch succeeds so both branches
of Promise.race always settle, avoiding a permanently pending promise
- Move resolution into .then() rather than .finally() so fetch failures
still propagate through Promise.race rejection
- Add test: setQueryData with undefined must NOT release suspense,
documenting the query.state.data !== undefined guard
Co-authored-by: atlarix-agent <agent@atlarix.dev>
* Update packages/query-core/src/queryObserver.ts
* test(queryObserver): cover cached data resolution
---------
Co-authored-by: DeepSeek V4 Pro agent <agent@atlarix.dev>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
'relativeLinkExists' builds the target path with 'path.resolve', which
uses the platform separator, but then matches it against '/examples/'
and rewrites it with a regex written in forward slashes.
On Windows the resolved path uses backslashes, so neither pattern
matches. Every documentation link that points at an example is looked up
as a markdown file under 'docs/framework/<name>/examples/' instead of a
directory under 'examples/<name>/', and 'pnpm test:docs' reports 27
broken links that are fine on CI.
Normalize the separators before the two comparisons. Node accepts
forward slashes on Windows, so the resolved path stays usable.
Co-authored-by: Yogesh Kumar <webdev1@futeservices.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* docs(solid-query/useQuery): document 'throwOnError' default value
* docs(solid-query/useQuery): document SSR and 'suspense' exceptions to 'throwOnError' default
* test(react-query/useQuery.promise): unskip 'cancelQueries' while suspending test by keeping 'queryFn' in-flight
* test(react-query/useQuery.promise): clarify why 'sleep' is extended in cancel-while-suspending test
* Protect restored custom-hash queries in devtools
Exercise the full dehydrate, hydrate, and query-row rendering path for a per-query custom queryKeyHashFn. This locks the queryHash lookup behavior introduced by #10750 and covers the persistence failure reported in #6958.
Constraint: The runtime lookup fix already shipped in #10750
Rejected: Reapply queryCache.get changes | current main already contains the implementation
Confidence: high
Scope-risk: narrow
Tested: query-devtools 246 tests; ESLint; TypeScript current; Prettier
Related: TanStack/query#6958
* test(query-devtools/Devtools): use 'advanceTimersByTimeAsync' for consistency and remove redundant 'clear'
* test(query-devtools/Devtools): move custom-hash hydration test to the end of 'query list'
* test(query-devtools/Devtools): align custom-hash test title with the 'when X' convention
---------
Co-authored-by: Wonsuk Choi <sukvvon@gmail.com>
* test(solid-query/useMutation): use the '.then()' convention consistently
* test(solid-query/useQuery): use the '.then()' convention consistently
* test(solid-query-persist-client): use the '.then()' convention consistently
* test({react,preact}-query/useInfiniteQuery): use the '.then()' convention consistently
* test({react,preact}-query/useMutation): use the '.then()' convention consistently
* test({react,preact}-query/useQueries): use the '.then()' convention consistently
* test({react,preact}-query/useQuery): use the '.then()' convention consistently
* test({react,preact}-query/usePrefetchQuery): inline the 'generateQueryFn' factory into each call site
* test({react,preact}-query/usePrefetchQuery): drop the unnecessary 'vi.fn()' wrapper on the never-asserted sentinel queryFn