* fix(types): propagate generic type params to useMutationState select callback
When TResult is a typed MutationState, the select callback parameter
now receives the correctly typed Mutation instead of the base Mutation type.
Adds a second type param TMutation (defaulting to MutationTypeFromResult<TResult>)
to MutationStateOptions across all five framework adapters. Uses a non-distributive
conditional type to avoid union expansion when TResult is unresolved.
Fixes#9825
* ci: apply automated fixes
* refactor(types): simplify useMutationState cast to mutation as TMutation
Replace the double-cast `(fn as unknown as (m: Mutation) => TResult)(m)`
with the direct `fn(m as TMutation)` across all five framework packages.
The constraint `TMutation extends Mutation<any, any, any, any>` creates
sufficient overlap for the single cast to compile cleanly on TS 5.4–6.0.
* fix(test): reorder imports in useMutationState.test-d.tsx per import/order rule
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(svelte-query): eliminate duplicate MutationTypeFromResult definition
Export MutationTypeFromResult from types.ts so useMutationState.svelte.ts
can import it instead of redefining it. Also normalises the else branch to
plain Mutation, matching every other adapter.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
Removing observers copied the full observer list on every unsubscribe, which got expensive when thousands of components shared a query. Splice the existing list in place instead.
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* refactor(eslint-plugin-query): remove unused ast-utils helpers
Remove five unused helpers from the ASTUtils object in ast-utils.ts:
getNestedIdentifiers, getNestedReturnStatements, getClosestVariableDeclarator,
mapKeyNodeToText and mapKeyNodeToBaseText.
None are referenced by any rule or other module, and ASTUtils is not part of
the package's public API (it is not exported from index.ts). knip does not flag
them because ASTUtils is exported as a single object, so member-level dead code
slips past it.
All 1709 tests pass and ast-utils.ts line coverage rises from 41% to 95%.
* chore: add changeset for unused ast-utils helper removal
---------
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* perf(query-core): Deduplicate tracked query properties
Each accessed useQueries result fans the same property out to every observer, making ordinary result mapping quadratic.
Track which properties have already been synchronized during the current result pass. This keeps the #7000 behavior while dropping the 10,000-result tracking benchmark from about 699 ms to under 1 ms locally.
Co-Authored-By: OpenAI Codex <noreply@openai.com>
* test(query-core): Cover repeated property tracking
Extend the existing tracking assertion to cover the same property being read from a second result.
Co-Authored-By: OpenAI Codex <noreply@openai.com>
---------
Co-authored-by: OpenAI Codex <noreply@openai.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* fix(lit-query): add DataTag to the queryKey returned by infiniteQueryOptions
* test(lit-query): cover error brand and callback updater for infiniteQueryOptions
---------
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
A query kept its last retryer for life, and the settled promise holds that
fetch's raw result: a second full copy of the data once a refetch has been
structurally shared into state.data, and still held after reset() or removal.
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* 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>