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>
* docs(example): dataloader
* use tanstack pacer instead of dataloader
* add staleTime
* switch to useAsyncBatchedCallback
* Revert "switch to useAsyncBatchedCallback"
This reverts commit 4d408daa63.
* fix: use PromiseWithResolvers
* add batching example to docs
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'