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
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
Arnoud
2283633684
docs(angular-query): update Angular Zoneless doc (#9616) 2025-09-04 14:05:23 +02:00
Tanner Linsley
1599bb4742 release: v5.86.0 v5.86.0 2025-09-04 09:27:33 +00:00
Dominik Dorfmeister
b25412a9e3
ref: rename queryFn to streamFn in streamedQuery (#9606)
* ref: rename queryFn to streamFn in streamedQuery

this avoids the weirdly double-nested queryFn naming

* chore: docs

* fix: docs
2025-09-04 11:19:15 +02:00
marco gobbi
8f24580fda
feat(query-core): add custom reducer support to streamedQuery (#9532)
* feat(query-core): add custom reducer support to streamedQuery

Replace maxChunks parameter with flexible reducer function that delegates
data aggregation to consumer code. This provides full control over how
streamed chunks are combined into the final data structure.

Add support for custom placeholderData that works seamlessly with the
reducer function, allowing initialization of complex data types beyond
simple arrays.

https://github.com/TanStack/query/discussions/9065

BREAKING CHANGE: The maxChunks parameter has been removed from streamedQuery.
Use a custom reducer function to control data aggregation behavior instead.

* ci: apply automated fixes

* feat(query-core): require initialValue when using custom reducer in streamedQuery

Add type safety by making initialValue mandatory when providing a custom
reducer function. This prevents runtime errors and ensures proper data
initialization for custom data structures beyond simple arrays.

Use conditional types to enforce the relationship between reducer and
initialValue parameters, maintaining backward compatibility for simple
array-based streaming while requiring explicit initialization for
custom reducers.

BREAKING CHANGE: When using a custom reducer function with streamedQuery,
the initialValue parameter is now required and must be provided.

* feat(query-core): require initialValue when using custom reducer in streamedQuery

Add type safety by making initialValue mandatory when providing a custom
reducer function. This prevents runtime errors and ensures proper data
initialization for custom data structures beyond simple arrays.

Use conditional types to enforce the relationship between reducer and
initialValue parameters, maintaining backward compatibility for simple
array-based streaming while requiring explicit initialization for
custom reducers.

BREAKING CHANGE: When using a custom reducer function with streamedQuery,
the initialValue parameter is now required and must be provided.

* feat(query-core): require initialValue when using custom reducer in streamedQuery

Add type safety by making initialValue mandatory when providing a custom
reducer function. This prevents runtime errors and ensures proper data
initialization for custom data structures beyond simple arrays.

Use conditional types to enforce the relationship between reducer and
initialValue parameters, maintaining backward compatibility for simple
array-based streaming while requiring explicit initialization for
custom reducers.

BREAKING CHANGE: When using a custom reducer function with streamedQuery,
the initialValue parameter is now required and must be provided.

* removed personal vscode workspace file

* updated documentation

* fix(docs): clarify reducer function description in streamedQuery documentation

* ci: apply automated fixes

* fix(tests): Code Review :: update streamedQuery tests to use correct initialValue type

---------

Co-authored-by: gobbimar <marco.gobbi@adidas.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-04 11:03:41 +02:00
Wonsuk Choi
43049c5534
test(react-query/useMutationState): clarify assertions and improve code formatting (#9611) 2025-09-03 10:35:56 +02:00
Wonsuk Choi
7306474eee
chore(tsconfig.json): simplify 'include' patterns by consolidating file extensions and directory paths (#9547)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-09-03 09:56:51 +02:00
BennettLiam
c75a994ca2
Fix svelte optimistic updates example (#8005)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-09-03 10:31:45 +09:00
Tanner Linsley
0a35234ce4 release: v5.85.9 v5.85.9 2025-09-02 12:17:18 +00:00
Kim YoungHoon
564a4f6e19
fix(query-core): ensure combine re-executes after cache restoration with memoized combine (#9592)
* fix(query-core): ensure combine re-executes after cache restoration with memoized combine

* fix(query-core): add error field to result change detection

* test(query-core): add test for QueriesObserver early return notification

* test(query-core): improve test for QueriesObserver early return notification

* refactor(query-core): use shallowEqualObjects for result comparison

* refactor(query-core): improve setQueries flow and fix persist/restore issue with memoized combine

* refactor(query-core): improve setQueries flow and remove log

* test(react-query): update useQueries expectations for metadata change detection

* test(react-query): fix test comments

* test(react-query): add test for stable combine optimization on unrelated re-renders

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-09-02 14:12:59 +02:00
Wonsuk Choi
5221029907
test(react-query/HydrationBoundary): add tests for 'non-object' state and missing 'queries' property handling (#9605)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-09-02 17:24:46 +09:00
Tanner Linsley
aec19c93a5 release: v5.85.8 v5.85.8 2025-09-02 07:59:16 +00:00
autofix-ci[bot]
c44ca473e4
ci: apply automated fixes 2025-09-02 07:54:17 +00:00
Minha Kang
ef0c16ecb1
refactor(react-query): replace magic number with named constant in suspense timers (#9607) 2025-09-02 09:53:28 +02:00
Tanner Linsley
a978b34b1b release: v5.85.7 v5.85.7 2025-09-02 07:22:33 +00:00
Flo
7d24156159
refactor(query-core): improve replaceEqualDeep performance (#9604)
* refactor(query-core): improve replaceEqualDeep performance

* try object.prototype that broke eslint in router

* no object flag

* improved version w/ more code

* ci: apply automated fixes

* less code, but still 2x faster

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
2025-09-02 09:18:20 +02:00
Vlad Kovechenkov
f97d7258a0
docs: mention second parameter for cancelQueries (#9597)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-09-02 12:08:19 +09:00
Imad Selka
0650eaf116
docs: clarify queryClient refetch behavior for stale queries (#9560)
* docs(queryClient): add example for refetchQueries with stale: true and type: active

* docs(react-native): modify useRefreshOnFocus example

* docs(react-native): add queryKey in useRefreshOnFocus example

* Apply suggestion from @TkDodo

* ci: apply automated fixes

---------

Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-09-01 12:53:17 +02:00
Tanner Linsley
b998f68a57 release: v5.85.6 v5.85.6 2025-08-30 12:21:11 +00:00
Dominik Dorfmeister
379670dd0a
fix(core): make sure queries revert synchronously (#9601)
the switch from the callback approach to async/await with catch was necessary to be able to transform errors into revert-state data for imperative query calls; however, this was a change in behavior because catch in async/await doesn't happen immediately - it runs in the next microtask. That opened up an opportunity for a slight race condition if we re-start a fetch in-between. And who does that? Of course, React Strict Mode.

This PR moves the actual state reverting back to a callback (so it happens synchronously), while still keeping the try/catch refactoring merely to transform the promise and the usual error handling
2025-08-30 14:19:17 +02:00
우혁
428c19fa33
docs: update mutation status type (#9595)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-30 14:47:27 +09:00
우혁
2a8ba49919
docs: remove unnecessary trailing comma (#9594)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-30 14:44:30 +09:00
우혁
54efe225b6
docs: fix type definitions in useQuery options (union, parameters, extra parentheses) (#9596)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-30 14:36:19 +09:00
우혁
ad0ca9f37c
docs: fix missing comma in useMutation example to prevent syntax errors (#9593)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-30 14:28:48 +09:00
Wonsuk Choi
a1b1279be3
test(react-query/useMutation): remove '@testing-library/jest-dom/vitest' import (#9569)
Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-20 12:58:59 +09:00
renovate[bot]
7c464e3ded
chore(deps): update marocchino/sticky-pull-request-comment digest to 9c40848 (#9473)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-08-19 12:29:46 +02:00
Kier Borromeo
1b0346fca8
docs: Updates examples for invalidation from mutations (#9261)
* Updates examples for invalidation from mutations

* ci: apply automated fixes

* Elaborate promise

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-19 12:23:41 +02:00
Dmytro Borysov
9a3f68373d
docs: Add not-prose class to browser logo images in devtools documentation (#9556) 2025-08-19 11:59:08 +02:00
Tanner Linsley
0a0e01443d release: v5.85.5 v5.85.5 2025-08-19 09:41:34 +00:00
Dominik Dorfmeister
abab082593
fix(core): only reject when promise gets used (#9576)
* fix(core): do not reject promise right away - only when `promise` gets used

* Apply suggestion from @TkDodo

* fix: status check
2025-08-19 11:39:34 +02:00
Tanner Linsley
ef0a9d2c7e release: v5.85.4 v5.85.4 2025-08-19 09:10:56 +00:00
Dominik Dorfmeister
e4f5ce8ec2
fix(core): never revert to undefined data (#9577)
* fix(core): never revert to undefined data

* fix: throw CancelledError for imperative fetches, but keep query reverted to idle state

* chore: improve test
2025-08-19 11:09:11 +02:00
Lee
2989e69dc0
docs(react-query): recommend defaultError = unknown instead of AxiosError (#9575)
* docs(react-query): recommend defaultError = unknown instead of AxiosError

Signed-off-by: leesb971204 <leesb971204@gmail.com>

* docs(react-query): clarify usage of defaultError in global Error type registration

Signed-off-by: leesb971204 <leesb971204@gmail.com>

* ci: apply automated fixes

* docs(solid-query): recommend defaultError = unknown instead of AxiosError

Signed-off-by: leesb971204 <leesb971204@gmail.com>

* docs(angular-query): recommend defaultError = unknown instead of AxiosError

Signed-off-by: leesb971204 <leesb971204@gmail.com>

* docs(vue-query): add example code for Registering a global Error

Signed-off-by: leesb971204 <leesb971204@gmail.com>

---------

Signed-off-by: leesb971204 <leesb971204@gmail.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-08-18 17:46:32 +02:00
TkDodo
f1e608bcac docs: update community resources 2025-08-18 12:19:08 +02:00
Tanner Linsley
b6516bd25e release: v5.85.3 v5.85.3 2025-08-14 13:05:50 +00:00
Dominik Dorfmeister
51aad7ddf7
fix(query-core): race condition in StrictMode (#9565) 2025-08-14 15:04:05 +02:00
TkDodo
de3626a368 test(core): tests for StrictMode behaviour 2025-08-14 13:49:05 +02:00
Tanner Linsley
e14f39c6ee release: v5.85.2 v5.85.2 2025-08-14 08:51:42 +00:00
Dominik Dorfmeister
0991576781
fix(query-core): query cancellation and reverting (#9293)
* fix: we don't want errors that get reverted internally to throw on imperative methods

to achieve that, we let the retryer's `onError` "transform" the result back to potentially TData, and if so, we'll resolve the promise to that instead; that means calls to `fetchQuery` will be "successful" when a cancellation happens in the meantime, but they will then resolve to the reverted data; also, if the initial fetch is cancelled, we would still throw, as there is no data to revert to.

* refactor: async/await

* minimal test adjustments

* test: fix it

* fix: revertState is now a local variable

* fix: make sure "silent" reverts do not reject ongoing promises

up until now, silent reverts have only stopped the query from going into error state, but the exposed promise was still rejected

now, the promise won't reject because a silent revert indicates another refetch happening, so we'd want to get that promise's result instead

this also means "silent" is an internal thing that shouldn't be used by consumers, because it can lead to never resolving promises instead

* chore: bring back isCancelledError and deprecate it

* test: revert changes

* test: minimal adjustment to timings
2025-08-14 10:49:58 +02:00
Tanner Linsley
31f51b97fa release: v5.85.1 v5.85.1 2025-08-14 07:57:58 +00:00
Dominik Dorfmeister
4806dfaf23
fix(query-core): have revertState capture manual updates (#9558) 2025-08-14 09:56:12 +02:00
TkDodo
9ae770b9d0 chore: update bundle-size badges to react 19.1.1 2025-08-14 09:50:27 +02:00
Tanner Linsley
aab51d9398 release: v5.85.0 v5.85.0 2025-08-12 12:41:10 +00:00
Alem Tuzlak
c63713fc38
feat: add solid devtools panel export to solid devtools (#9551)
* feat: add solid devtools panel export to solid devtools

* ci: apply automated fixes

* fix knip + eslint

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
2025-08-12 14:37:39 +02:00
Dmytro Borysov
6402d756b7
chore: update browser icons (#9555) 2025-08-11 18:22:20 +02:00
Dmytro Borysov
d25c0da344
docs: Add Firefox and Edge browser extension support to devtools docs (#9548)
- Add browser logos for Chrome, Firefox, and Edge
- Update devtools documentation across all frameworks to include Firefox and Edge extensions
- Replace Chrome-only messaging with multi-browser support
- Add inline browser icons with links to respective extension stores
2025-08-11 13:08:47 +02:00
Lubos
763cee3e16
Add oRPC to community projects for TanStack Query (Vue) (#9539)
* Add oRPC to community projects for TanStack Query (Vue)

* Update oRPC link to TanStack Query integration

This should make oRPC more relevant when people search for things like "orpc tanstack query"

---------

Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-10 03:58:05 +09:00
Lubos
fba477ba2b
Add oRPC to community projects for TanStack Query (React) (#9538)
* Add oRPC to community projects for TanStack Query (React)

* Update oRPC link to TanStack Query integration

This should make oRPC more relevant when people search for things like "orpc tanstack query"

---------

Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-10 03:52:50 +09:00
Lubos
3a999ccd9f
Add Hey API to community projects for TanStack Query (Vue) (#9535)
* Add Hey API to community projects for TanStack Query (Vue)

* Update Hey API link to TanStack Query plugin

This should make Hey API more relevant when people search for things like "openapi tanstack query"

---------

Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-10 03:48:20 +09:00
Lubos
0455d58bd7
Add Hey API to community projects for TanStack Query (React) (#9534)
* Add Hey API to community projects for TanStack Query (React)

* Update Hey API link to TanStack Query plugin

This should make Hey API more relevant when people search for things like "openapi tanstack query"

---------

Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
2025-08-10 03:44:39 +09:00