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

5,168 commits

Author SHA1 Message Date
MINSEONG KIM
53fc74ebb1
fix(query-core): fix combine not updating when queries change with stable reference (#9954)
* test(query-core, react-query): add tests for stable combine reference with dynamic queries

* fix(query-core): fix combine cache invalidation with stable reference

* chore: add changesets

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2026-01-16 16:24:43 +01:00
Ulrich Stark
0d07172687
chore: remove unnecessary type assertions (#10028)
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2026-01-16 13:07:36 +01:00
github-actions[bot]
64d5d623c8
ci: Version Packages (#10045) @tanstack/angular-query-experimental@5.90.22 @tanstack/query-async-storage-persister@5.90.20 @tanstack/query-broadcast-client-experimental@5.90.18 @tanstack/query-core@5.90.18 @tanstack/query-persist-client-core@5.91.17 @tanstack/query-sync-storage-persister@5.90.20 @tanstack/react-query-persist-client@5.90.20 @tanstack/react-query@5.90.18 @tanstack/solid-query-persist-client@5.90.21 @tanstack/solid-query@5.90.21 @tanstack/svelte-query-persist-client@6.0.18 @tanstack/svelte-query@6.0.16 @tanstack/vue-query@5.92.7
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-01-16 11:56:19 +01:00
Seoku
dea1614aaa
fix(query-core): avoid throwing promise errors when data exists (#10025)
* fix(query-core): avoid throwing promise errors when data exists

* test(react-query): cover refetch error behavior with promise + infinite query

* chore(changeset): add query-core patch for prefetch error handling

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2026-01-16 11:43:33 +01:00
Daniel Bondarenko
4e8be3f46f
docs: clarify that failureCount starts at 0 in retry callback (#10031)
Added clarification that failureCount parameter in the retry callback
function starts at 0 for the first retry attempt, not 1.

Fixes #10017
2026-01-16 11:24:55 +01:00
github-actions[bot]
bf7f47e6be
ci: Version Packages (#10033) @tanstack/angular-query-experimental@5.90.21 @tanstack/query-async-storage-persister@5.90.19 @tanstack/query-broadcast-client-experimental@5.90.17 @tanstack/query-core@5.90.17 @tanstack/query-persist-client-core@5.91.16 @tanstack/query-sync-storage-persister@5.90.19 @tanstack/react-query-persist-client@5.90.19 @tanstack/react-query@5.90.17 @tanstack/solid-query-persist-client@5.90.20 @tanstack/solid-query@5.90.20 @tanstack/svelte-query-persist-client@6.0.17 @tanstack/svelte-query@6.0.15 @tanstack/vue-query@5.92.6
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-01-13 20:36:06 +01:00
Flo
269351b8ce
fix(query-core): replaceEqualDeep max depth (#10032)
* fix(query-core): replaceEqualDeep max depth

* restore expected error in unit test

* ci: apply automated fixes

* Update max depth for replaceEqualDeep function

Fixes the max depth for replaceEqualDeep in query-core.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2026-01-13 18:49:12 +01:00
Wonsuk Choi
44c3cb965b
test(react-query/ssr): add 'useQueries' test for SSR (#9996) 2026-01-11 17:21:37 +09:00
TkDodo
f61647443d chore: size-limit 2025-12-31 10:33:53 +01:00
Martin Meixger
14c0ec89d0
docs: fix missing param in vue infinite queries sample (#10004)
* docs: fix missing param in vue infinite queries sample

Add initialPageParam to useInfiniteQuery

* docs: fix missing param in vue infinite queries sample
2025-12-30 23:27:54 +01:00
github-actions[bot]
167db32642
ci: Version Packages (#10005) @tanstack/angular-query-experimental@5.90.20 @tanstack/query-async-storage-persister@5.90.18 @tanstack/query-broadcast-client-experimental@5.90.16 @tanstack/query-core@5.90.16 @tanstack/query-persist-client-core@5.91.15 @tanstack/query-sync-storage-persister@5.90.18 @tanstack/react-query-persist-client@5.90.18 @tanstack/react-query@5.90.16 @tanstack/solid-query-persist-client@5.90.19 @tanstack/solid-query@5.90.19 @tanstack/svelte-query-persist-client@6.0.16 @tanstack/svelte-query@6.0.14 @tanstack/vue-query@5.92.5
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-30 15:44:57 +01:00
sangwook
4be3ad730c
fix(react-query): allow retryOnMount when throwOnError is function (#9336) (#9338)
* test(react-query): add tests should retry on mount when throwOnError returns false

* fix(react-query): refine throwOnError retry logic for error boundary cases
When throwOnError is a function, allow retryOnMount to proceed even when error boundary hasn't reset,
while maintaining the prevention behavior for boolean throwOnError values.

* fix(react-query): enhance throwOnError logic in error boundaries

Refine behavior to handle function-type throwOnError, allowing retries when appropriate. Ensure boolean throwOnError values still prevent retries when the error boundary isn't reset.

* test: Add tests for `throwOnError` behavior in `useQuery`

This commit introduces tests to verify the behavior of the `throwOnError` callback in scenarios where `retryOnMount` is enabled. It ensures proper handling of retries based on the error state and the `throwOnError` function's return value. These tests improve the reliability and coverage of error handling logic in `useQuery`.

* fix(react-query): improve throwOnError logic with query state validation

- Pass query object to ensurePreventErrorBoundaryRetry for accurate state checking
- Preserve query deduplication behavior while fixing throwOnError function handling
- Fixes issue where throwOnError function couldn't access query error state

* fix(react-query): fix test flakiness and query cache timing (#9338)

- Replace vi.waitFor with vi.advanceTimersByTimeAsync in tests
- Use separate render results to avoid stale DOM references
- Inline fresh query lookup in ensurePreventErrorBoundaryRetry after _experimental_beforeQuery

* ci: apply automated fixes

* fix(react-query): refine retryOnMount logic and error boundary handling

- move query retrieval after `_experimental_beforeQuery` in `useBaseQuery`
- refactor `ensurePreventErrorBoundaryRetry` for better clarity
- make `query` parameter required in `ensurePreventErrorBoundaryRetry`

* ci: apply automated fixes

* feat(react-query): make query param required but nullable in ensurePreventErrorBoundaryRetry

* Apply suggestions from code review

* chore: size-limit

* chore: changeset

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-30 15:39:24 +01:00
Nima Rahnema
7f47906eac
fix(query-core): fix queriesObserver result and observer length mismatch (#9973)
In 1b54538, `setOptions` was changed to call `notifyListeners` which
eventually leads to `QueriesObserver.setQueries`

1. Updating `#observerMatches`
2. Calling `setOptions` which leads to `#notify` being called
3. Updating `#result`

This is an issue when `#notify` is called before the `#result` is
updated, as `#trackResult` assumes these two are the same length, which
may not be the case if the number of queries changed. When the length
increases, `observerResult` becomes `undefined` and the function throws
an exception.

Fix by moving the `#observerMatches` assignment later in the function,
next to the `#observers` and `#result` assignment.

Co-authored-by: nrahnema <nrahnema@hudson-trading.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-30 15:39:03 +01:00
github-actions[bot]
0a1e3e0e05
ci: Version Packages (#10003) @tanstack/angular-query-experimental@5.90.19 @tanstack/query-async-storage-persister@5.90.17 @tanstack/query-broadcast-client-experimental@5.90.15 @tanstack/query-core@5.90.15 @tanstack/query-persist-client-core@5.91.14 @tanstack/query-sync-storage-persister@5.90.17 @tanstack/react-query-persist-client@5.90.17 @tanstack/react-query@5.90.15 @tanstack/solid-query-persist-client@5.90.18 @tanstack/solid-query@5.90.18 @tanstack/svelte-query-persist-client@6.0.15 @tanstack/svelte-query@6.0.13 @tanstack/vue-query@5.92.4
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-29 16:52:59 +01:00
xiangnuan
fccef797d5
fix(query-core): ensure query refetches on mount/retry when status is error (#9728) (#9927)
* fix(query-core): ensure query refetches on mount/retry when status is error (#9728)

* fix: mark queries as invalidated on background errors instead of checking error status

- Remove error status check in shouldFetchOn
- Set isInvalidated: true in reducer when background error occurs (only if data exists)
- Add tests for staleTime: 'static' and non-static queries with background errors

This approach centralizes stale logic in isStale/isStaleByTime and prevents
regression where staleTime: 'static' queries would incorrectly refetch on
window focus after a background error.

* refactor: simplify isInvalidated logic in error case

Set isInvalidated: true unconditionally since queries with no data
are always considered stale per isStaleByTime logic.

* Apply suggestion from @TkDodo

* Apply suggestions from code review

* fix: eslint

* fix: disable retry in background error tests to prevent timeout

The tests were timing out because when refetch() throws an error, the
default retry mechanism (3 retries with exponential backoff) was being
triggered. With fake timers, the retry delays weren't being advanced,
causing the tests to hang.

Adding retry: false to both tests disables retries and allows them to
complete immediately after the error, which is appropriate for these
tests that specifically check background error behavior.

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-29 16:36:15 +01:00
Simon Schick
e907f89c64
fix(core): report errors of useMutation callbacks asynchronously (#9676)
* Ensure errors of useMutation callbacks onError and onSettled are reported asynchronously

* Fixed accidental removal of vitests unhandledRejection handler

* chore: size-limit

---------

Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-28 20:22:05 +01:00
Simon Schick
3ee1ae47f8
fix(core): report errors of mutation callbacks asynchronously (#9675)
* Ensure errors of mutation callbacks are reported asynchronously

* Fixed accidental removal of vitests unhandledRejection handler

---------

Co-authored-by: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-28 20:12:30 +01:00
github-actions[bot]
84564f1293
ci: Version Packages (#10001) @tanstack/angular-query-experimental@5.90.18 @tanstack/query-async-storage-persister@5.90.16 @tanstack/query-broadcast-client-experimental@5.90.14 @tanstack/query-core@5.90.14 @tanstack/query-devtools@5.92.0 @tanstack/query-persist-client-core@5.91.13 @tanstack/query-sync-storage-persister@5.90.16 @tanstack/react-query-devtools@5.91.2 @tanstack/react-query-persist-client@5.90.16 @tanstack/react-query@5.90.14 @tanstack/solid-query-devtools@5.91.2 @tanstack/solid-query-persist-client@5.90.17 @tanstack/solid-query@5.90.17 @tanstack/svelte-query-devtools@6.0.3 @tanstack/svelte-query-persist-client@6.0.14 @tanstack/svelte-query@6.0.12 @tanstack/vue-query-devtools@6.1.3 @tanstack/vue-query@5.92.3
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-28 17:02:35 +01:00
HuijungYoon
d576092e2e
fix(query-core): prevent reducer from being called twice in streamedQuery (#9970)
* fix(query-core): prevent reducer from being called twice in streamedQuery #9787

- Fix bug where reducer was called twice for each chunk (once in setQueryData, once in loop)
- Store reducer result in variable to avoid duplicate calls
- Add test case to verify reducer is only called once per chunk

* fix(streamed-query): prevent reducer from being called twice

Fixed an issue where the reducer was being invoked twice when refetchMode is set to 'replace'.
Added a regression test to verify the fix.

Fixes #9787

* docs: add changeset and lockfile update

* fix(changeset): change version bump to patch

* Update streamedQuery.test.tsx

fix: lint

* fix: support refetchMode append and prevent double reducer calls

- Fix refetchMode append to preserve existing data on refetch
- Fix reducer being called twice by calling it once and storing result
- Update pnpm-lock.yaml to match main branch

* chore: update pnpm-lock.yaml to include size-limit dependencies

* ci: apply automated fixes

* refactor: simplify streamedQuery logic with clearer isReplaceRefetch condition

- Extract isReplaceRefetch variable for better readability
- Use explicit if-else instead of negated conditions
- Make it clearer when reducer is called in each branch

---------

Co-authored-by: TkDodo <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-28 15:30:40 +01:00
Matthew Costabile
f9fc56a9b8
fix(devtools): Handle some additional query devtools accessibility findings (#9961)
* improve a11y again

* ci: apply automated fixes

* changeset

* more granular read

* add valuemin

* a few more nits

* fix mouseUp

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-28 15:21:24 +01:00
Ji-hoon Choi
0b29b6f877
fix(devtools): handle PiP open failures by resetting persisted state (#9983)
fix: handle PiP open failures by resetting persisted state

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-28 15:02:10 +01:00
Wonsuk Choi
642f72d699
test(react-query/ssr): add 'useIsFetching' test for SSR (#9994) 2025-12-28 14:14:04 +01:00
dilmuhammad abdumalikov
31e3db527a
Enhance scroll restoration documentation for TanStack Query (#9987)
* Enhance scroll restoration documentation for TanStack Query

Explain how TanStack Query improves scroll restoration in SPAs by caching data and preventing UI resets.

* Update docs/framework/react/guides/scroll-restoration.md

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-28 11:29:15 +01:00
Dominik Dorfmeister
e722679e16
ref: move size-limit config to its own file (#9998)
* ref: move size-limit config to its own file

to avoid cache busting everything when the limits change

* ref: update size-limit
2025-12-28 10:25:52 +01:00
github-actions[bot]
1d20c486ae
ci: Version Packages (#9997) @tanstack/react-query-persist-client@5.90.15
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-28 10:10:24 +01:00
razhayat
4a0a78afbc
fix: streamed query consume aware signal (#9963)
* chore: move consume aware signal logic to utils

* fix: add consume aware signal to streamedQuery

* test: add a test for not a signal that is not consumed by streamFn

* chore: add changeset

* fix: made queryFn of streamedQuery not consume signal directly (so that only streamFn can consume it)

* fix: made onCancelled get called only once

* fix: memoized getSignal and made sure it is called only once

* fix: no-unnecessary-condition

* chore: size-limit

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-28 10:06:55 +01:00
TkDodo
5810292b38 fix: size-limit 2025-12-27 18:05:51 +01:00
TkDodo
51b895c718 fix: size-limit 2025-12-27 18:02:48 +01:00
TkDodo
dd45407927 fix: run size-limit with --json 2025-12-27 17:56:48 +01:00
Dominik Dorfmeister
afc64091cd
feat: size-limit (#9993)
* feat: size-limit

* fix: script

* fix: add test:size to nx

* fix: skip install and build

* really

* fix: size-limit options

* ok we need build step

* fix: test-size runs as part of its own action
2025-12-27 17:33:07 +01:00
Tanner Linsley
f64ac77e83
Update bundlephobia link to TanStack React Query (#9990)
docs: update bundlephobia links to @tanstack/react-query

The bundlephobia links were pointing to the old react-query package (v3)
instead of the current @tanstack/react-query package.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-27 13:01:45 +01:00
Talgat Minigaliev
bdec357b9e
docs: Modify onMutate signature to add context parameter (#9982)
Updated the onMutate function signature to include context.
2025-12-27 12:31:21 +01:00
Wonsuk Choi
7a3990eba7
test(solid-query/useQuery): migrate to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', and improve 'queryFn' patterns (#9894)
* test(solid-query/useQuery): migrate to fake timers with 'advanceTimersByTimeAsync', add 'expect().toBeInTheDocument()', convert sync 'queryFn' to 'sleep().then()', and add detailed timing comments

* test(solid-query/useQuery): replace 'async/await' with 'sleep().then()' pattern in queryFn

* refactor(solid-query/useQuery.test): convert complex 'then' callbacks to async/await pattern
2025-12-27 12:27:20 +01:00
Wonsuk Choi
2be25ca08d
test(react-query/HydrationBoundary): add tests for 'enabled: false' and 'staleTime: Infinity' (#9969)
* test(react-query/HydrationBoundary): add tests for 'enabled: false' and 'staleTime: Infinity'

* chore: trigger CI

* test(react-query/HydrationBoundary): add delayed assertions for 'enabled: false' and 'staleTime: Infinity' tests
2025-12-27 12:26:53 +01:00
Wonsuk Choi
e63673b7fb
test(svelte-query-persist-client/PersistQueryClientProvider): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', and use 'sleep().then()' pattern (#9900)
* test(svelte-query-persist-client/PersistQueryClientProvider): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', and use 'sleep().then()' pattern

* test(svelte-query-persist-client/PersistQueryClientProvider): replace 'setQueryDefaults' with 'onFetch' callback in FreshData

* refactor(svelte-query-persist-client/FreshData): convert complex 'then' callback to async/await pattern
2025-12-27 12:26:24 +01:00
Wonsuk Choi
968fb43ad8
test(angular-query-persist-client/withPersistQueryClient): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', use 'sleep().then()' pattern, replace 'screen' with 'rendered', add 'toBeInTheDocument', and add '@testing-library/jest-dom/vitest' (#9895)
* test(angular-query-persist-client/withPersistQueryClient): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', use 'sleep().then()' pattern, replace 'screen' with 'rendered', add 'toBeInTheDocument', and add '@testing-library/jest-dom/vitest'

* test(angular-query-persist-client/withPersistQueryClient): replace 'async/await' with 'sleep().then()' pattern in queryFn and restoreClient

* refactor(angular-query-persist-client/withPersistQueryClient.test): convert complex 'then' callbacks to async/await pattern
2025-12-27 12:24:42 +01:00
Wonsuk Choi
573bf58eaf
test(solid-query-persist-client/PersistQueryClientProvider): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', and use 'sleep().then()' pattern (#9892)
* test(solid-query-persist-client/PersistQueryClientProvider): switch to fake timers, replace 'waitFor' with 'advanceTimersByTimeAsync', and use 'sleep().then()' pattern

* refactor(solid-query-persist-client/PersistQueryClientProvider.test): convert complex 'then' callback to async/await pattern
2025-12-27 12:23:36 +01:00
Wonsuk Choi
6161dcd121
test(react-query-persist-client/PersistQueryClientProvider): convert complex 'then' callback to async/await and add delayed assertion for refetch verification (#9901)
* test(react-query-persist-client/PersistQueryClientProvider): replace 'await sleep' with 'sleep().then()' pattern in restoreClient and add additional timer advance for refetch verification

* refactor(react-query-persist-client/PersistQueryClientProvider.test): convert complex 'then' callbacks to async/await pattern
2025-12-27 12:22:58 +01:00
Ofek Lavie
8471715987
docs: Document possible conflict between PersistQueryClientProvider and SSR streaming (#9979)
* Add docs about PersistQueryClientProvider settings

* correct

* Apply suggestion from @TkDodo

* Apply suggestions from code review

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-12-26 20:36:05 +01:00
Bailey Lissington
ecf9696c08
docs: correct grammar (#9953) 2025-12-26 20:33:39 +01:00
Elias Witt
23f636c674
docs: fix small grammar mistake (#9992) 2025-12-26 20:33:14 +01:00
Shumyla Farid
ee16773c70
docs: clarify cache time in caching guide for useQuery (#9967)
Clarify cache time in caching guide for useQuery
2025-12-21 15:01:52 +01:00
BrysonXiao
84d98445c4
docs: Update prefetching.md to fix typo (#9984)
A "be" was missing in the paragraph.
2025-12-21 14:35:13 +01:00
Lachlan Collins
f15b7fcc01
ci: prepare for trusted publishing (#9952)
* ci: prepare for trusted publishing

* Format

* Remove NPM_TOKEN
2025-12-07 01:47:55 +11: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
github-actions[bot]
9e8709eddb
ci: Version Packages (#9945) @tanstack/angular-query-experimental@5.90.16 @tanstack/query-async-storage-persister@5.90.14 @tanstack/query-broadcast-client-experimental@5.90.12 @tanstack/query-core@5.90.12 @tanstack/query-persist-client-core@5.91.11 @tanstack/query-sync-storage-persister@5.90.14 @tanstack/react-query-persist-client@5.90.14 @tanstack/react-query@5.90.12 @tanstack/solid-query-persist-client@5.90.15 @tanstack/solid-query@5.90.15 @tanstack/svelte-query-persist-client@6.0.12 @tanstack/svelte-query@6.0.10 @tanstack/vue-query@5.92.1
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-12-04 12:12:48 +01:00
Dominik Dorfmeister
72d8ac5c59
fix: update react and nextJs (#9944)
* fix: update react and nextJs

and add a nextJs16 integration test

* ci: apply automated fixes

* oops

* Update patch versions for React and TanStack packages

Updated the patch versions for various React and TanStack packages.

* fix: streamline dependencies

* bundle size

* fix lock file

* fix: update react in example

* skip test for now

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-04 10:10:29 +01:00
Lachlan Collins
7e99b885ff
docs: fix sidebar links (#9933) 2025-11-30 08:08:25 +11:00
Lachlan Collins
7f4939c624
ci: sync config between projects (#9931)
* ci: update typedoc

* Remove old check
2025-11-29 19:55:40 +11:00
Lachlan Collins
b7b452e407
ci: remove @tanstack/publish-config (#9930)
* ci: remove @tanstack/publish-config

* Update imports
2025-11-29 16:22:35 +11:00