The `createRawRef` Proxy used by `createQueries` crashed with
`TypeError: 'deleteProperty' on proxy: trap returned falsish for property 'N'`
whenever the reactive query list was shrunk by two or more items in one update.
Two compounding causes:
1. `update()` iterated `keysToRemove` in ascending index order. The trap
decrements `target.length` after every deletion, so the next stale index
was no longer `in target` and the trap returned `false`, which throws in
strict mode (ES modules).
2. The trap returned `false` for missing props instead of treating delete on
a nonexistent prop as a spec-compliant no-op.
Fix: sort `keysToRemove` descending for arrays so each delete acts on the
current tail, and return `true` from `deleteProperty` when the prop is
already absent.
Generated by Ora Studio
Vibe coded by ousamabenyounes
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
fix(svelte-query): track keys added to an empty createRawRef
createQueries stayed permanently inactive when it was initialized with an
empty queries array. Reads of an absent index have no $state.raw field to
subscribe to, and length is a plain array property, so a consumer that
observed the result while it was empty registered no reactive dependency
and never re-ran once queries were added.
Track those reads through a key version that update() bumps whenever the
key set changes.
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
The type narrowing example wraps useQuery() in reactive() without saying
why, so destructuring the result directly and then checking isSuccess
looks like it should work (#9244). Spell out that reactive() is what
flattens the refs into one discriminated union, and show the
data.value !== undefined check as the alternative when reactive() is not
an option.
Pin both shapes with type tests: the non-reactive result exposes
Ref<T> | Ref<undefined>, and narrowing on data.value refines the ref
itself.
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* fix(broadcast-client): recover from errors thrown while applying an incoming cross-tab message
If applying an incoming cross-tab message (query.setState/queryCache.build,
which notifies observers) throws, the internal `tx()` helper's `transaction`
flag was never reset. This silently disabled all future outgoing broadcasts
from this tab for the rest of the session. Guard with try/finally so a single
failed message can't permanently break cross-tab sync.
* test(broadcast-client): also cover the query.setState throw path
The existing regression test only exercised queryCache.build (a brand-new
remote query hash). Add a case where the incoming message targets an
existing query, so an exception during query.setState is exercised too.
Addresses CodeRabbit review feedback on #11242.
* feat(vue-query): add new methods to vue-query
* docs(vue-query): docs for new impertive methods for Vue
* fix(vue-query): remove getter options from impertive methods
There is no evidence that the () => queryOptions getter type is
properly used by `fetchQuery` et al, as while it accepts a getter in the
types, it doens't resolve the function at runtime (as opposed to
`useQuery`). Removing the type from `query` and `fetchQuery` and
documenting calling getters impertivly as a workaround.
* Update packages/vue-query/src/queryClient.ts
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* Update packages/vue-query/src/usePrefetchQuery.ts
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
---------
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
Ports #9338 to preact-query: ensurePreventErrorBoundaryRetry now
receives the cached query and evaluates a function-form throwOnError
against the actual error before setting retryOnMount = false, instead
of treating any function as truthy. Includes the regression tests
from #9338, two of which fail on current main.
Fixes#11165
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* fix(broadcast-client): handle unhandled postMessage rejections
Wrap channel.postMessage() calls in safePost() to catch DataCloneError
and similar failures that occur when query data contains non-cloneable
values (ReadableStream, Response, Vue reactive proxies, etc.).
Adds an optional onBroadcastError callback to BroadcastQueryClientOptions
so consumers can pipe errors to Sentry/Datadog. Falls back to console.warn
in development when the callback is not provided.
Fixes#10543
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(broadcast-client): guard against throwing onBroadcastError callback
Wrap onBroadcastError() in a try/catch so that if the callback itself
throws, the error does not escape as an unhandled rejection. Falls back
to console.warn in development when the callback throws.
Add a test asserting no unhandledRejection fires when onBroadcastError throws.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(broadcast-client): handle async onBroadcastError rejections
Support async onBroadcastError callbacks by calling .catch() on the
returned Promise, preventing unhandled rejections when the callback
rejects asynchronously.
Also extracts the console.warn fallback into warnBroadcastError to
deduplicate the warning logic.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(broadcast-client): use try/finally to ensure unhandledRejection listener cleanup
Prevents listener leaks into subsequent tests if an assertion throws
before process.off() is reached.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(broadcast-client): improve types, messages, and docs
- Export BroadcastErrorEvent interface with QueryKey typing so consumers
can import the type directly
- Use discriminated union for internal BroadcastMessage (state only on
updated) for more precise typing
- onBroadcastError now receives BroadcastErrorEvent (no internal state
field) instead of the raw BroadcastMessage
- Differentiate dev warning messages: broadcast failures explain the
structured-clone cause and consequence; onBroadcastError failures
explicitly identify the hook as the source
- Remove warnBroadcastError helper in favour of context-specific inlined
warn calls
- Fix duplicate queryClient.getQueryCache() call (use queryCache directly)
- Add JSDoc to all BroadcastQueryClientOptions fields
- Add onBroadcastError section to broadcastQueryClient docs with Sentry
example
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(broadcast-client): assert warn message when onBroadcastError throws or rejects
Add two tests that verify the '[broadcastQueryClient] onBroadcastError
threw while handling...' console.warn message is emitted in development
when the onBroadcastError callback itself throws synchronously or rejects
asynchronously.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(broadcast-client): include state in 'added' broadcasts
The receiver's onmessage handler reads state for 'added' events to call
query.setState(state) and queryCache.build(..., state), but the sender
was not including state in the outbound message. This caused receiving
tabs to apply undefined state for newly added queries.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(broadcast-client): wrap warnSpy in try/finally to prevent spy leakage
If an assertion fails before mockRestore(), the console.warn spy would
leak into subsequent tests. Wrapping each spy block in try/finally
ensures restore always runs regardless of test outcome.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* ci: apply automated fixes
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Removing an observer in place can shift the active notification loop and skip the next observer. Iterate over a shallow copy so synchronous unsubscriptions keep the old behavior without giving up the faster removal path from #11214.
Co-authored-by: Codex <noreply@openai.com>
* fix(lit-query): migrate to standard tsup build so 'build' output is cached by nx and 'test:build' passes
* chore(lit-query): align 'package.json' and rename 'vitest.config.ts' to 'vite.config.ts' to match react-query, drop obsolete knip 'src/tests' ignore
* fix(lit-query): migrate build from 'tsup' to 'tsdown' to match other adapters
* docs(.changeset): update 'lit-query' changeset to reference 'tsdown' instead of 'tsup'
* fix(query-core): release the retryer once a mutation settles
Mutation.execute() never cleared #retryer after settling, so the settled
retryer's promise kept that mutation's result, variables and context
reachable for as long as the MutationCache retained the Mutation. Mirror
the treatment Query.fetch() received in #11163, guarded by an identity
check so a mutation re-executed from a cache callback keeps its own
retryer.
Releasing the retryer alone would change continue(): a settled mutation
no longer has a retryer to continue, so it would fall through to
execute() and run the mutationFn a second time. Both internal callers
filter on state.isPaused and never reach a settled mutation, but
continue() is reachable directly, so the fallback is now gated on the
mutation still being pending -- the same condition execute() already uses
to detect a restored mutation.
Fixes#11216
* test(query-core): assert the settled retryer is actually released
The previous tests only guarded the continue() gating and passed on main
too, so they did not demonstrate the fix. continue() is the only reader
of #retryer outside execute(): while a settled retryer is still held it
hands back that retryer's promise, which resolves with the raw result it
closed over (or rejects with its error). Both new tests fail on main and
pass with the retryer released.
---------
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
* 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>