0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
Commit graph

421 commits

Author SHA1 Message Date
Wonsuk Choi
345bb3d372
docs(angular-query-experimental): add 'readonly' to class fields in JSDoc examples (#11416) 2026-09-06 13:03:46 +09:00
Wonsuk Choi
9810709718
docs(angular-query-experimental): add JSDoc across the package (#11406)
* docs(angular-query-experimental): add JSDoc across the package and generate reference docs with TypeDoc

* docs(angular-query-experimental): address CodeRabbit review comments on JSDoc accuracy

* docs(angular-query-experimental): use 'changes' instead of 'narrows' for select's effect on TData
2026-09-06 12:12:24 +09:00
Wonsuk Choi
85de9c35ac
docs(svelte-query): regenerate reference docs to fix stale source line numbers (#11399) 2026-09-05 13:43:50 +09:00
Wonsuk Choi
309508612a
docs(vue-query): add JSDoc and generate reference docs with TypeDoc (#11378)
* docs(vue-query): add JSDoc across the package

* docs(vue-query): generate reference docs with TypeDoc

* docs(config): register vue-query TypeDoc reference pages

* docs(vue-query): preserve dehydrate/hydrate option docs and fix reference links

* docs(config): reorder vue-query reference nav to list 'Functions' first

* docs(config): reorder vue-query 'Functions' entries to match react/preact grouping

* docs(vue-query): restore Suspense guide link and 'placeholderData' behavior note lost in TypeDoc migration

* docs(vue-query): correct JSDoc accuracy issues and reactivity bugs

* docs(vue-query): fix invalidateQueries example that invalidated every query, add whole-options getter example

* docs(vue-query): add examples for the mutationOptions and useInfiniteQuery getter overloads

* docs(vue-query): add react-parity examples for select, skipToken, keepPreviousData, optimistic updates, and infinite scroll

* docs(vue-query): add queryOptions select typing example to useQueries

* docs(vue-query): disconnect IntersectionObserver on unmount, drop non-null assertion in skipToken examples

* docs(vue-query): add 'skipToken' factory example to 'queryOptions'

* docs(vue-query): correct 'queryKey' reactive-getter claim in 'useQuery'/'useInfiniteQuery'

* docs(vue-query): correct 'queryKey' reactive-getter claim in 'QueryOptions' type JSDoc

* docs(vue-query): fix reversed claim that 'queryKey' entries can't be reactive getters
2026-09-05 13:29:11 +09:00
Wonsuk Choi
fc51e96045
docs(react-query, preact-query): use 'button' instead of undefined 'Button' in suspense guide examples (#11390) 2026-09-04 16:00:13 +09:00
Wonsuk Choi
9ea8ea0030
docs(preact-query): fix broken TkDodo link mangled by 'react-query'->'preact-query' replace (#11389) 2026-09-04 16:00:02 +09:00
Jooyoung Shin
ec3f992cbf
docs(preact-query): add 'Suspense' and 'Testing' guides (#11377)
docs(preact-query): add Suspense and Testing guides

The Preact docs had no counterpart for the React "Suspense" and
"Testing" guides even though `@tanstack/preact-query` ships the
suspense hooks and `QueryErrorResetBoundary`.

Follow the existing Preact docs convention: reference the React guide
via `ref:` + `replace:` and override only the React-specific sections
(`preact/compat` Suspense, an error boundary built on `useErrorBoundary`,
`@testing-library/preact`). The React guides only gain the section
markers needed for the overrides; their wording is unchanged.
2026-09-04 15:11:20 +09:00
Wonsuk Choi
b81a6396c6
docs(preact-query): add 'The Query Options API' link, matching react's queryOptions JSDoc (#11388) 2026-09-04 12:04:31 +09:00
Wonsuk Choi
19c96a5134
docs(solid-query): remove 'The Query Options API' link, solid's queryOptions API differs from react's (#11387) 2026-09-04 11:42:55 +09:00
Wonsuk Choi
b4f5736437
docs(react-query): fix run-on sentence and subject-verb agreement in SSR guide (#11382) 2026-09-03 23:02:00 +09:00
Wonsuk Choi
d29e7cf0b5
docs(preact-query): fix XSS-unsafe example and missing 'staleTime' in SSR guide (#11381) 2026-09-03 23:00:16 +09:00
Wonsuk Choi
2c5ba585ac
docs(preact-query): add 'Server Rendering & Hydration' guide (#11380)
* docs(preact-query): add 'Server Rendering & Hydration' guide

* docs(preact-query): add 'serializeData'/'deserializeData' to SSR guide
2026-09-03 21:48:01 +09:00
Wonsuk Choi
a29ca68867
docs: redirect flat reference URLs broken by the TypeDoc migration (#11379)
* chore(scripts/generate-docs): inject 'redirect_from' into flat reference URLs

* docs(react-query, solid-query): add 'redirect_from' for URLs broken by the TypeDoc migration
2026-09-03 18:08:28 +09:00
Wonsuk Choi
fe77cdc8d7
docs({react,preact,solid}-query): correct inaccurate JSDoc statements (#11372)
* docs(react-query): correct inaccurate JSDoc statements

* docs(preact-query): correct inaccurate JSDoc statements

* docs({react,preact,solid}-query): stop implying useQueries options are fully identical to useQuery
2026-09-03 10:42:36 +09:00
Wonsuk Choi
de8ab4db3e
docs(solid-query): add JSDoc and generate reference docs with TypeDoc (#11369)
* docs(solid-query): add JSDoc across the package

* docs(solid-query): generate reference docs with TypeDoc

* docs(config): register solid-query TypeDoc reference pages

* docs(solid-query): correct inaccurate JSDoc statements flagged in review
2026-09-03 10:19:23 +09:00
Wonsuk Choi
1a5331a2ab
docs(preact-query): correct inaccurate JSDoc statements (#11367)
* docs(preact-query): correct inaccurate JSDoc statements

* docs(preact-query): regenerate reference docs
2026-09-02 16:25:19 +09:00
Wonsuk Choi
4c568a28c8
docs(react-query): generate reference docs with TypeDoc (#11366)
* docs(vue-query,solid-query): inline react reference content instead of 'ref'-ing hand-written react docs

* docs(react-query): generate reference docs with TypeDoc

* docs(vue-query,solid-query): fix dangling suspense-hook links left over from the react content copy

* docs(solid-query): apply solid's callback call form to inlined reference examples

* docs(react-query): correct inaccurate JSDoc statements flagged in review

* docs(vue-query,solid-query): fix reactivity-aware examples and inaccurate type signatures flagged in review

* docs(vue-query,solid-query): fix remaining type/behavior inaccuracies flagged in second review

* docs(react-query): stop implying a default queryFn defers a fetch the way 'enabled: false' does

* docs(vue-query): mark 'mutate'/'mutateAsync' per-call options as optional
2026-09-02 16:06:54 +09:00
Wonsuk Choi
f6ae1ccdf7
feat(svelte-query): add 'DefinedInitialDataInfiniteOptions' overload for 'createInfiniteQuery'/'infiniteQueryOptions' (#11356)
* feat(svelte-query): add 'DefinedInitialDataInfiniteOptions' overload for 'createInfiniteQuery'/'infiniteQueryOptions'

* chore(.changeset): use conventional commits pattern for changeset entry

* ci: apply automated fixes

* docs(svelte-query): regenerate reference docs for infinite-query initialData overload and update changeset entry

* docs(svelte-query): regenerate reference docs after merging main's JSDoc examples

* docs(svelte-query): revert unrelated line-number-only doc diffs

* docs(svelte-query): drop generated reference doc changes from this type-only PR

* chore(.changeset): match changeset entry to the PR title/commit subject

* docs(svelte-query): regenerate reference docs for the new infinite-query overloads

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-09-01 21:59:20 +09:00
Wonsuk Choi
dd9216c92a
docs(svelte-query): add JSDoc '@example's across hooks and options factories (#11352)
* docs(svelte-query): add JSDoc '@example's across hooks and options factories

* docs(svelte-query): add missing 'isPending' idiom and 'mutateAsync' examples

* docs(svelte-query): address CodeRabbit review feedback on JSDoc examples

* docs(svelte-query): correct 'pending' status description in createQuery's @returns

* docs(svelte-query): add missing 'initialData' example to infiniteQueryOptions
2026-09-01 21:07:52 +09:00
Wonsuk Choi
a85d4f16c9
docs(preact-query): correct 'pending' status description in useQuery's @returns (#11354) 2026-09-01 16:55:30 +09:00
Wonsuk Choi
acf8a3631f
docs(preact-query): rename onError's third example parameter from 'context' to 'onMutateResult' (#11353) 2026-09-01 15:50:46 +09:00
Wonsuk Choi
2b44804d18
docs(preact-query): add 'select' example to 'useQuery' (#11343)
* docs(preact-query): add 'select' example to 'useQuery'

* docs(preact-query): move 'select' example right after the basic 'useQuery' example

* docs(preact-query): make 'select' example derive a different type instead of a subset
2026-08-31 12:29:20 +09:00
Wonsuk Choi
6a732234c7
docs(preact-query): remove hover-prefetch example from 'useQuery'/'useInfiniteQuery' (#11341) 2026-08-31 09:39:25 +09:00
Wonsuk Choi
87fa4c1628
docs(preact-query): define 'App' before 'ErrorBoundary' in 'QueryErrorResetBoundary' example (#11338) 2026-08-31 02:52:42 +09:00
Wonsuk Choi
9633f7998f
docs(preact-query): add 'QueryErrorResetBoundary' and 'ErrorBoundary' to 'useSuspenseQuery'/'useSuspenseInfiniteQuery'/'useSuspenseQueries' examples (#11337)
* docs(preact-query): add 'ErrorBoundary' to 'useSuspenseQuery'/'useSuspenseInfiniteQuery'/'useSuspenseQueries' examples

* docs(preact-query): correct suspense error contract wording ('data'/query error, no-cached-data condition)
2026-08-31 02:42:06 +09:00
Wonsuk Choi
ffcf9a365e
docs(preact-query): trim 'queryOptions'/'infiniteQueryOptions' examples to what the factory needs to prove (#11336)
docs(preact-query): trim 'queryOptions'/'infiniteQueryOptions' examples to what the factory itself needs to prove
2026-08-31 01:08:50 +09:00
Wonsuk Choi
08dc65a9b5
docs(preact-query): inline 'useQuery''s basic-example options instead of a 'queryOptions' factory (#11331) 2026-08-30 15:26:58 +09:00
Wonsuk Choi
d5402b9284
docs(preact-query): improve JSDoc examples across hooks and options factories (#11301)
* docs(preact-query): wrap 'useIsFetching' example in a component

* docs(preact-query): wrap 'useQueries' examples in components and add 'isError' handling

* docs(preact-query): wrap 'useIsMutating' and 'useMutationState' examples in components

* docs(preact-query): wrap 'queryOptions' examples in components

* docs(preact-query): wrap 'infiniteQueryOptions' example in a component

* fix(preact-query): correctly distinguish error state from loading in 'infiniteQueryOptions' example

* fix(preact-query): correct mutation terminology and filter by success status in 'useMutationState' examples

* docs(preact-query): destructure useInfiniteQuery result in 'infiniteQueryOptions' example

* docs(preact-query): rename 'variables' to 'pendingVariables' in 'useMutationState' example

* docs(preact-query): rename 'data' to 'savedPosts' in 'useMutationState' examples

* docs(preact-query): rename 'results'/'result' to 'addResults'/'addResult' in 'useMutation' Promise.allSettled example

* docs(preact-query): rename 'latest' to 'latestSavedPost' in 'useMutationState' example

* docs(preact-query): render fetched pages and handle loading/error states in 'useInfiniteQuery' examples

* docs(preact-query): render infinite query lists as '<ul>'/'<li>' instead of flat '<p>' tags

* docs(preact-query): show hover-triggered prefetch instead of an unlocated 'Elsewhere' comment in 'queryOptions'/'infiniteQueryOptions' examples

* docs(preact-query): move hover-prefetch examples from 'queryOptions'/'infiniteQueryOptions' to 'useQuery'/'useInfiniteQuery'

* docs(preact-query): render list examples as '<ul>'/'<li>' and fix undefined refs across remaining hooks

* docs(preact-query): name the prefetch id in 'queryOptions'/'infiniteQueryOptions' examples instead of an unexplained literal

* docs(preact-query): add 'skipToken' examples for type-safe conditional disabling

* docs(preact-query): use 'isLoading' with optional chaining in the infinite-query 'skipToken' examples

* docs(preact-query): add missing 'isPending'/'isError' handling across 'queryOptions'/'useQuery'/'infiniteQueryOptions'/'useInfiniteQuery' examples

* docs(preact-query): keep 'initialData' examples showing data alongside errors instead of hiding it

* docs(preact-query): use scroll-triggered pagination in 'useInfiniteQuery' examples, add a 'fetchNextPage' trigger to 'infiniteQueryOptions'

* docs(preact-query): guard scroll-triggered 'fetchNextPage' with 'isFetching', move cross-reference out of '@example'

* docs(preact-query): move duplicated usage examples from 'queryOptions'/'infiniteQueryOptions' into their hooks

* docs(preact-query): remove duplicated basic-mutation example from 'mutationOptions', trim boilerplate '@remarks'

* docs(preact-query): add 'combine' example to 'useSuspenseQueries', link 'useSuspenseInfiniteQuery' to 'useInfiniteQuery' and document its waterfall/refetch risks

* docs(preact-query): drop irrelevant 'useSuspenseQueries' reference from 'useSuspenseInfiniteQuery' waterfall remark

* docs(preact-query): strengthen 'useMutation''s '@see' pointer to 'mutationOptions' with its 'mutationKey' lookup benefit

* docs(preact-query): add blank lines around 'isPending'/'isError' guards for consistency with other examples
2026-08-30 13:15:47 +09:00
Wonsuk Choi
44645e9eb1
docs(preact-query): rename 'results' to 'postQueries' in 'useSuspenseQueries' example (#11299) 2026-08-26 15:16:52 +09:00
Wonsuk Choi
dbd8fbab49
docs(preact-query): document request-waterfall avoidance across 'useSuspenseQuery' and 'useSuspenseQueries' (#11298)
* docs(preact-query): warn about request waterfalls and point to 'useSuspenseQueries' in 'useSuspenseQuery'

* docs(preact-query): add multiple-parallel-queries example to 'useSuspenseQueries'
2026-08-26 14:52:10 +09:00
Wonsuk Choi
e17de345ce
docs(preact-query): remove redundant 'infiniteQueryOptions' usage from 'useInfiniteQuery' examples (#11297) 2026-08-26 13:59:02 +09:00
Wonsuk Choi
904ab016b0
docs(preact-query): use function declarations instead of arrow functions in example code (#11296) 2026-08-26 13:44:13 +09:00
Wonsuk Choi
f6ed6e4bde
docs(preact-query): expand JSDoc @example coverage across hooks (#11295)
* fix(preact-query): guard 'fetchNextPage' example with 'isFetching', not just 'isFetchingNextPage'

* docs(preact-query): add global loading indicator example to 'useIsFetching'

* docs(preact-query): add mutation-state, 'Promise.all', and 'Promise.allSettled' examples to 'useMutation'

* docs(preact-query): add 'isPending'/'isError' example alongside 'status' to 'useQuery'

* docs(preact-query): fix dependent-query example in 'useQuery' to use 'isLoading' instead of 'isPending'

* docs(preact-query): add pagination example with 'keepPreviousData' to 'useQuery'

* docs(preact-query): correct consecutive-mutation callback wording in 'useMutation' example

* docs(preact-query): add per-call 'onError' callback to basic 'useMutation' example

* docs(preact-query): use contextual message in 'console.error' for 'Promise.all' example in 'useMutation'
2026-08-26 13:31:02 +09:00
Wonsuk Choi
d09cf1d605
docs(preact-query): backtick bare code-symbol references in JSDoc ('QueryClient', 'suspense', 'throwOnError') (#11290)
* docs(preact-query): wrap bare 'QueryClient' type name in backticks in JSDoc

* docs(preact-query): backtick 'QueryClient' in 'children' prop doc and 'suspense'/'throwOnError' in QueryErrorResetBoundary
2026-08-26 00:14:24 +09:00
Wonsuk Choi
e6503b0990
docs(preact-query): cross-link hooks with their options factories via '@see' and move the infinite-query caveat to '@remarks' (#11289) 2026-08-25 23:28:25 +09:00
Wonsuk Choi
0a16a362dd
docs(preact-query): tag 'subscribed' with '@defaultValue' for structured default-value rendering (#11288) 2026-08-25 23:15:31 +09:00
Wonsuk Choi
84b4f13470
docs(preact-query): document type parameters with '@template' and add 'useQueryClient' throws note (#11285)
* docs(preact-query): document type parameters with '@template' and add 'useQueryClient' throws note

* docs(preact-query): fix TQueryData select direction and TResults/TDepth phrasing flagged by CodeRabbit
2026-08-25 21:28:15 +09:00
Wonsuk Choi
5bb950be80
docs(preact-query): document interfaces and type aliases with JSDoc for generated reference docs (#11284)
* docs(preact-query): document interfaces and type aliases with JSDoc for generated reference docs

* docs(preact-query): fix finite/infinite mix-ups and opaque-array fallback claims flagged by CodeRabbit
2026-08-25 19:35:48 +09:00
Wonsuk Choi
720725d113
docs(preact-query): import 'noop' from '@tanstack/preact-query' instead of '@tanstack/query-core' in examples (#11283) 2026-08-25 17:06:26 +09:00
Wonsuk Choi
870bd854cc
docs(preact-query): document functions and components with JSDoc for generated reference docs (#11204)
* docs(preact-query): document functions and components with JSDoc for generated reference docs

* docs(preact-query): replace concrete API calls with abstract fetcher names in JSDoc examples

* docs(preact-query): rename mutation example fetcher to be CRUD-neutral

* docs(preact-query): rename mutation example fetcher to 'createPosts'

* docs(preact-query): add examples for Suspense, prefetch, and options-builder functions

* docs(preact-query): add optimistic update, dependent query, and SSR hydration examples

* docs(preact-query): add parameterized factory and mutationKey lookup examples to queryOptions/mutationOptions

* docs(preact-query): add infiniteQueryOptions factory example and restore useMutationState's third example

* docs(preact-query): add TkDodo-inspired multi-API reuse, initialData, and per-call mutate callback examples

* docs(preact-query): document useIsRestoring, initialData, mutateAsync, and skipToken-excluded queryFn fields

* docs(preact-query): fill in empty Returns sections for hooks and options builders

* docs(preact-query): systematic sweep of generated pages for missing field descriptions and fix mismatched mutationOptions example

* docs(preact-query): split mutationOptions' mutationKey overload into basic usage and lookup examples

* docs(preact-query): fix overloads whose example didn't match their initialData-required type

* docs(preact-query): fill overloads missing examples and useSuspenseQueries' queryClient param description

* docs(preact-query): remove duplicated overload example and fix examples that failed type-checking

* docs(preact-query): describe every documented parameter and restore reverted overload example

* docs(preact-query): describe children props and low-level context exports

* fix(preact-query): remove inaccurate 'queryFn is optional' claim from infiniteQueryOptions overload

* docs(preact-query): add missing @returns to mutationOptions overloads and provider components

* docs(preact-query): describe QueryErrorResetBoundary children and its render-function parameter

* docs(preact-query): fix prose-accuracy issues found by multi-agent audit

Corrects useQuery's first overload @returns to match its actual return
type, moves the useSuspenseQuery/useSuspenseInfiniteQuery cancellation
caveat out of the @returns block, softens overstated skipToken/queryFn
claims, merges a duplicated useMutationState description, and adds
missing JSDoc to QueryErrorResetBoundary's function-type aliases and
UseMutateFunction/UseMutateAsyncFunction.

* docs(preact-query): soften remaining overstated queryFn requirement in Suspense options

* docs(preact-query): fix inaccurate prose in hydration, queryFn, and useQueries docs

* docs(preact-query): correct hydration freshness gate, placeholderData arity, and deprecated 'fetchInfiniteQuery' reference

* docs(preact-query): remove leftover 'data is never undefined' claim in 'useInfiniteQuery' overload docs

* docs(preact-query): replace deprecated 'prefetchQuery'/'prefetchInfiniteQuery' calls in examples with 'query'/'infiniteQuery'

* docs(preact-query): point 'usePrefetchQuery' JSDoc at 'queryClient.query' to match its actual option type
2026-08-25 16:43:01 +09:00
Wonsuk Choi
8fbfc14d42
chore(examples,docs): replace deprecated 'prefetchQuery'/'fetchQuery' calls with 'query' (#11282) 2026-08-25 15:06:52 +09:00
Wonsuk Choi
0c36448862
docs: regenerate TypeDoc reference for angular, svelte, preact, lit (#11267) 2026-08-24 10:20:01 +09:00
Ciarán Curley
40321a0b1b
docs: add docs for simplified query methods (#10662)
docs: add docs for simplfied impertive query methods

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-22 21:04:36 +02:00
Davyd NRB
5ca904d068
Enhance DevTools support with Rozenite Plugin (#10328)
Updated the DevTools support section to include the Rozenite Plugin for React Native DevTools users, enhancing the available debugging options.
2026-08-22 10:28:39 +02:00
Ben Younes
b8517d3173
docs(vue-query): explain why reactive() is needed for result narrowing (#10580)
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>
2026-08-22 10:20:36 +02:00
Ciarán Curley
e6748265c8
React: update usePrefetchQuery to use new methods, plus react adaptor tests and docs (#10668)
* feat(react-query): update usePrefetchQuery to use new imperitive methods plus tests

* docs(react-query): new docs for usePrefetchQuery

* Update .changeset/warm-candies-like.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/react-query/src/usePrefetchInfiniteQuery.tsx

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>

* Update packages/react-query/src/usePrefetchQuery.tsx

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-20 18:35:32 +02:00
Ciarán Curley
4e48c581b7
Preact: update usePrefetchQuery to use new methods with docs (#10669)
* feat(preact-query): use new methods for usePrefetchQuery plus tests

* docs(preact-query): updated docs for usePrefetchQuery

* Update docs/framework/preact/reference/interfaces/UsePrefetchInfiniteQueryOptions.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update packages/preact-query/src/usePrefetchInfiniteQuery.tsx

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>

* Update packages/preact-query/src/usePrefetchQuery.tsx

Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister 🔮 <office@dorfmeister.cc>
2026-08-20 18:35:10 +02:00
Ciarán Curley
97ce30b51e
Vue: add new impertive methods to vue proxy QueryClient (#11208)
* 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>
2026-08-20 17:12:42 +02:00
Dominik Dorfmeister 🔮
1ef42087c9
ref: remove experimental_prefetchInRender (#11221) 2026-08-20 11:32:10 +02:00
n-satoshi061
3c79861ab1
fix(broadcast-client): handle unhandled postMessage rejections (#10771)
* 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>
2026-08-20 10:24:33 +02:00