Repository navigation
Conversation
… 'retry' options A query hydrated while pending resumes the dehydrated promise through a retryer created at hydration time, before any observer has set the query's options. Its retries used the 'retry' and 'retryDelay' the query had then, so an observer's 'retry: false' or 'retryDelay' was ignored. Read 'retry' and 'retryDelay' from the query's options at the time of each failure for fetches that resume an 'initialPromise'. Other fetches keep the options they started with. Co-authored-by: alexander <alexander@n1s.se>
… with 'using' Co-authored-by: alexander <alexander@n1s.se>
… with 'using' Adds a 'subscribe' helper to @tanstack/query-test-utils that returns a Disposable, and a test for it and for 'clearOnDispose'. Co-authored-by: alexander <alexander@n1s.se>
Co-authored-by: alexander <alexander@n1s.se>
…ions Co-authored-by: alexander <alexander@n1s.se>
…de hydration Client defaults and setQueryDefaults no longer count as set, so they don't override hydrate.queries.retry. Co-authored-by: alexander <alexander@n1s.se>
…the observer's retry Co-authored-by: alexander <alexander@n1s.se>
🦋 Changeset detectedLatest commit: c351a29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
This was referenced Nov 3, 2026
…d them Use the files' own fake timers and clean up with unsubscribe() and clear(), as the other tests do. Remove the clearOnDispose, fakeTimers and subscribe helpers from @tanstack/query-test-utils. Co-authored-by: alexander <alexander@n1s.se>
A hydrated fetch now reads retry and retryDelay from the query's current options at each failure, falling back to the options it started with. This drops the changes to infiniteQueryBehavior.ts, queryClient.ts and utils.ts, and replaces the hydration tests with two that fail without the fix. Co-authored-by: alexander <alexander@n1s.se>
A hydrated query's retries take retry and retryDelay from the options an observer set itself, then the hydration options, then the client's defaults. defaultQueryOptions records the options it was called with, so the query can tell an observer's own options from defaults. Co-authored-by: alexander <alexander@n1s.se>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
We made this PR with AI help and haven't yet done the two steps in TanStack's AI Contribution Policy. We still need to check that we understand all the code, and to rewrite this description in our own words.
🎯 Changes
When
dehydrateincludes a pending query,hydrateresumes its promise on the client. That fetch starts before any observer mounts, so its retryer tookretryandretryDelayfrom the options the query had at hydration. IfuseQuerymounted withretry: false, or a differentretryDelay, before the server promise rejected, the hydration options still decided whether and when the query retried.Now, when a query hydrated while pending rejects, its retries take
retryandretryDelayfrom, in order:useQueryor other observer set itself,defaultOptions.queriespassed tohydrateorHydrationBoundary,defaultOptions.queriesandsetQueryDefaults).A
useQuerymerges client defaults into its options before it creates the observer, so the query can't tell from the observer's options alone which values the caller set.queryClient.defaultQueryOptionstherefore records the options it was called with, in a module-levelWeakMapkeyed by the object it returns. Options objects gain no new properties. The query reads the map only for fetches that resume a hydrated promise. Every other fetch keeps the options it started with, as before.New tests in
hydration.test.tsx:The first two fail without the fix. The third checks that the fix keeps the hydration options over the client's defaults.
This PR doesn't depend on #12512, and they share no code.
✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request. (Ran oxlint, knip,test:typesacross all TS versions and vitest for query-core and react-query, plus the docs link check.)🚀 Release Impact