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

32 commits

Author SHA1 Message Date
Wonsuk Choi
cb62f4f2ed
chore(*): adopt '@tanstack/oxlint-config' and '@tanstack/oxfmt-config', and fix the newly reported lint errors (#12555)
* chore(*): adopt '@tanstack/oxlint-config' and '@tanstack/oxfmt-config', and fix the newly reported lint errors

* chore(pnpm-lock.yaml): run 'pnpm dedupe'

* chore(scripts): move 'oxlint/plugin.ts' to 'oxlint-plugin.ts' to match the flat layout of 'scripts'

* chore(pnpm-workspace.yaml): update '@typescript-eslint/parser' and '@typescript-eslint/rule-tester' to '^8.72.1' to match the deduped '@typescript-eslint/utils'
2026-11-16 22:25:25 +09:00
VGontier
8be136b022
fix(query-persist-client-core): discard malformed persisted queries (#11919)
* fix(query-persist-client-core): handle nullish persisted query state

* fix(query-persist-client-core): validate deserialized queries

* fix(query-persist-client-core): validate persisted query fields

* fix(query-persist-client-core): narrow persisted entry validation

---------

Co-authored-by: Vivien Gontier <vivien.gontier@paygreen.fr>
Co-authored-by: Ciarán Curley <ciaran.curley.11.11@gmail.com>
2026-10-31 15:43:35 +00:00
Wonsuk Choi
650c69abcd
docs(framework): write snippet durations in 'count * unit * 1000' order (#12381) 2026-10-26 02:26:34 +09:00
Wonsuk Choi
56432b4a22
docs: use 'sh' instead of 'bash' for the shell code blocks (#12207) 2026-10-20 17:21:27 +09:00
Dami Oyeniyi
27cdf32c97
docs(persister): document asynchronous serialization callbacks (#11411)
Co-authored-by: grzdev <grzdev@users.noreply.github.com>
2026-09-14 15:32:30 +02:00
Wonsuk Choi
e57f8163b1
docs(query-core): add JSDoc across the package and expose it in generated reference docs (#11438)
* docs(query-core): add JSDoc across the package and expose it in generated reference docs

* docs(config.json): add sidebar entries for newly generated query-core reference docs

* docs(query-core): migrate remaining prose from the legacy 'docs/reference' pages into JSDoc

* docs(query-core): remove legacy 'docs/reference' pages superseded by the generated reference

* docs(query-core): regenerate reference docs after merging main

* docs(query-core): document missing default values for MutationOptions, combine, and QueryFilters.type

* fix(query-devtools): drop unnecessary 'query-core' project reference

* docs(query-core): document missing default values and normalize 'Defaults to' spacing

* docs(query-core): fix 'environmentManager' JSDoc example
2026-09-07 18:22:38 +02: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
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
max
79d2384db5
docs(*): fix 'homogenous', 'stoage', 'supressed', 'compoennts' spelling typos (#11040)
* fix: correct spelling typos across docs, examples, and source comments

- homogenous -> homogeneous in 7 useQueries/createQueries source files
- stoage -> storage in react and vue createPersister docs
- supressed -> suppressed in react and angular pagination examples
- compoennts -> components in solid-start-streaming example

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(react-query/useSuspenseQueries): correct 'homogenous' typo to 'homogeneous' in comment

---------

Co-authored-by: maxtaran2010 <ocotifuzo727@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Wonsuk Choi <sukvvon@gmail.com>
2026-07-13 14:06:03 +09:00
René Klomp
978fc52728
feat(experimental_createQueryPersister): Add removeQueries (#10186)
* Add removeQueries

* Docs

* ci: apply automated fixes

* Fix test

* Add changeset

* Udpate docs

* Await removeItem

* Improve test names

* Update .changeset/fifty-zebras-stay.md

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

* Add coderabbitai suggestion

* More data integrity checks

* removeItem if deserialize fails

* removeItem if deserialize fails in retrieveQuery as well

* removeItem if deserialize fails in restoreQueries

* Revert changes outside removeQueries scope

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-02-26 12:44:41 +01:00
Lachlan Collins
5ad78fc4ad
docs: correct local relative links (#9947)
* docs: correct local relative links

* Update links

* Slight tweaks

* String
2025-12-05 22:39:25 +11:00
Damian Osipiuk
5cd86c6ef1
fix(query-persist-client-core): add option to change behavior of refetch after restore (#9745) 2025-10-10 23:04:23 +02:00
Jake Teton-Landis
a0b96db937
feat(query-core): add timeoutManager to allow changing setTimeout/setInterval (#9612)
* add timeoutManager class

* add additional types & export functions

* convert all setTimeout/setInterval to managed versions

* tweaks

* add claude-generated tests

* tests

* revert changes in query-async-storage-persister: no path to import query-core

* re-export more types

* console.warn -> non-production console.error

* query-async-storage-persister: use query-core managedSetTimeout

* pdate pnpm-lock for new dependency edge

* sleep: always managedSetTimeout

* remove managed* functions, call method directly

* remove runtime coercion and accept unsafe any within TimeoutManager class

* cleanup; fix test after changes

* name is __TEST_ONLY__

* notifyManager: default scheduler === systemSetTimeoutZero

* Improve TimeoutCallback comment since ai was confused

* remove unnecessary timeoutManager-related exports

* prettier-ify index.ts (seems my editor messed with it already this pr?)

* continue to export defaultTimeoutProvider for tests

* oops missing import

* fix: export systemSetTimeoutZero from core

* ref: use notifyManager.schedule in createPersister

because it needs to work with whatever scheduleFn we have set there

* ref: move provider check behind env check

* docs

* doc tweaks

* doc tweaks

* docs: reference timeoutManager in discussion of 24 day setTimout limit

* Apply suggestion from @TkDodo

* Apply suggestion from @TkDodo

* chore: fix broken links

* docs: syntax fix

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-09-05 13:37:09 +02:00
Dominik Dorfmeister
1078bce264
refactor: deprecate createSyncStoragePersister (#9316) 2025-06-27 15:52:38 +02:00
Dominik Dorfmeister
f052bf2642
fix(docs): Update persistQueryClient.md 2025-06-27 11:09:37 +02:00
Braden Wong
dfbda9de66
refactor(types): revert narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)" (#9251)
This reverts commit 982f6ca607.
2025-06-05 15:04:37 +02:00
René Klomp
9e0e60c7f0
fix(experimental_createQueryPersister): Change persisterRestoreAll to restoreQueries with filter support (#9230)
* Add persisterRestoreByKey

* Fix imports

* Add missing return statement

* Fix test

* docs

* Add extra test

* Merge into single restoreQueries function
2025-06-04 20:37:26 +02:00
Braden Wong
982f6ca607
refactor(types): narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void (#9202)
* refactor: narrow onSuccess/onError/onMutate/onSettled callback types to Promise<void> | void

Previously, the `onSuccess`, `onError`, `onMutate`, and `onSettled` callbacks were typed as `() => Promise<unknown> | unknown`. While `unknown` is technically valid, it implies that the return value might be used, assigned, or further processed. However, throughout the codebase, these callbacks are invoked solely for their side effects, and their return values are always ignored. Narrowing the type to `Promise<void> | void` makes this intent explicit, clarifies that any return value will be discarded, and prevents misleading type signatures that suggest otherwise.

This commit narrows their types to `() => Promise<void> | void`, which more accurately reflects their intended use.

* docs: update callback return types to Promise<void> | void in mutation-related documentation

This commit refines the documentation for mutation-related callbacks (`onSuccess`, `onError`, `onSettled`, and `onMutate`), changing their return types from `Promise<unknown> | unknown` to `Promise<void> | void`.
2025-06-02 18:09:24 +02:00
Tanner Linsley
afc6302dbf docs: fix links
commit 113eb6ba963534fe80b3e96193d767bf769c8bff
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 23:16:11 2025 -0600

    docs: fix: only transform generated reference

commit d1d084ed9026e31ba746e1bb87d5c19183a7d148
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 23:12:07 2025 -0600

    docs: fix broken links

commit 0df59ea7d8afb16be86ae917fc46900b6e999351
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 15:54:19 2025 -0600

    fix: rewrite type doc links to be directory-relative

commit 81e4c71f1c9250005f164b7e585837ee0ad14e23
Author: Tanner Linsley <tannerlinsley@gmail.com>
Date:   Fri May 23 15:14:51 2025 -0600

    fix: initial fix for ./ => ../
2025-05-24 00:47:55 -06:00
Damian Osipiuk
65ef198ad8
fix(experimental_createQueryPersister): return more utilities, rename persister (#8062)
* fix(experimental_createQueryPersister): return more utilities, rename persister

* chore: some docs

* test: add tests for utilities

* ci: apply automated fixes

* fix: add missing await

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-05-13 23:39:40 +02:00
David Madner
2e1282ca03
fix(persistQueryClientRestore): better error handling for persistQueryClientRestore (#8969)
* fix(persistQueryClientRestore): Do not swallow exceptions during in persistQueryClientRestore within `restoreClient` and `removeClient`

* fix: rethrow errors in removeClient within all branches

* fix: test for PersistQueryClientProvider in all consumers

* chore: implement PR feedback

* chore: mock console calls, so they do not end up in the console. This way we can also assert on the invocations

* chore: consoleWarn mocks to be restored after each test

* chore: remove tmp file commited accidentally

* chore: adjust docs and include new optional callback `onError`

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-04-10 18:13:17 +02:00
spookyuser
b18972fab5
docs: update createPersister.md with info about cache mutations (#8893)
* Update createPersister.md with info about https://github.com/TanStack/query/issues/6310

* Fix typo

* ci: apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-04-10 14:02:45 +02:00
TkDodo
4b7fd0e836 docs: fix internal links 2025-03-18 09:45:11 +01:00
Ruud Andriessen
397fcfc141
docs: prefer using satisfies instead of type cast in persistQueryClient docs (#8551) 2025-01-20 17:26:19 +01:00
Alex Liu
4521a04a25
docs: use correct broadcastChannel default value and type name (#8436) 2024-12-16 16:14:41 +01:00
Mackie Underdown
6768a9c723
docs(createSyncStoragePersister): fix typo (#7348) 2024-04-29 17:17:32 +02:00
fuko
8fa82653dd
docs: fix broken internal links in the query docs (#7247)
* wip - 1

* Fix more links

* Fix one more link

* Another one

* Update a link

* Fix the broken links in the Angular docs

* Fix the broken links in the Vue docs

* Fix the Svelte links in the docs

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2024-04-22 10:38:13 +02:00
Tanner Linsley
754640a3e5
docs: migrate docs to use path-based navigation instead of route-based (#7211)
TanStack Router uses path-based navigation instead of route-based navigation, so many of the relative documentation links will be invalid after migration. This fixes that.
2024-04-02 16:46:31 -06:00
Gioele Vuaran
0123c8094d
docs: gcTime max value (#7190) 2024-04-02 17:15:08 +02:00
Ekam Ahuja
d83aa272fb
docs: Updated installation commands with bun package manger (#6971) 2024-02-25 10:15:32 +01:00
Lachlan Collins
5a5b61b19b
docs: Fix relative link depth (#6778) 2024-01-26 19:53:40 +11:00
Lachlan Collins
0cdbd5a198
docs: Re-organise for new docs layout (#6763)
* docs: Re-organise for v2 docs layout

* Add $schema
2024-01-26 07:57:22 +11:00