* perf(query-core): Skip unused query result tracking
QueriesObserver was building tracked results on every update even when there was no combine function to consume them. Skip that work for normal useQueries notifications.
Co-Authored-By: Codex <noreply@openai.com>
* ref(query-core): Reuse combine skip check
Treat a missing combine function as another reason to skip combining. This keeps the notification flow close to the existing code and only defers result tracking.
Co-Authored-By: Codex <noreply@openai.com>
* ref(query-core): Match combine presence check
Use the same truthiness check as combineResult so null and other falsy runtime values follow the existing no-combine behavior.
Co-Authored-By: Codex <noreply@openai.com>
---------
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* fix(vue-query): preserve TQueryKey inference with generic params (#8199)
The mapped UseQueryOptions type wrapped queryKey in
MaybeRefDeep<DeepUnwrapRef<TQueryKey>>. The recursive DeepUnwrapRef on a
generic TQueryKey is opaque to TS's homomorphic mapped type inference,
so TQueryKey collapsed to its default (QueryKey) when useQuery was
called from a composable that propagates a generic into the queryKey.
For the queryKey property only, drop DeepUnwrapRef and use a single-
level MaybeRef<TQueryKey> wrap. Inference now binds TQueryKey to the
supplied queryKey shape; queryFn still receives DeepUnwrapRef<TQueryKey>
via the existing mapping for non-queryKey properties.
Co-Authored-By: Ora Studio <noreply@oratelecom.net>
* test(vue-query): strengthen #8199 regression assertion with explicit TData
Per CodeRabbit feedback: bare assertType(useBasket('fruit')) only verified
the call compiled, which would still pass under the old buggy behavior
(TQueryKey collapsing to QueryKey, TData inferred as unknown). Lock the
regression by asserting the propagated TData explicitly.
---------
Co-authored-by: Ora Studio <noreply@oratelecom.net>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* chore: tsup -> tsdown
* revert size-limit and fix the build instead
* fix angular and devtools build
* fix nextJs builds
* more solid related things
* fix: import order
* fix(query-core): clear stale select error when observer switches to a query without data
* fix(query-core): reset isPlaceholderData on select-error results
---------
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* 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>