GeezerVison is showing github.com — fix(query-core): release the retryer once a fetch settles by codebytere-ant · Pull Request #11163 · TanStack/query
Conversation
🎯 Changes
Query.fetch() leaves #retryer set after the fetch settles. The retryer's resolved promise still holds the raw result of that fetch, so once a query has refetched it holds its data twice: the structurally shared objects in state.data, plus the fresh result the promise resolved with. It also means reset() and removeQueries() don't free the data while anything still points at the query.
This clears #retryer in the existing finally once the fetch has settled. The identity check is there so a fetch started synchronously from a cache onSuccess/onSettled callback keeps its own retryer. The other readers of #retryer are already behind ?. or a fetchStatus check, so the only visible change is that query.promise is undefined after a fetch has settled instead of the settled promise.
✅ Checklist
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit
-
Bug Fixes
- Released query retry resources after fetches settle, queries reset, or queries are removed.
- Prevented settled promises from retaining unnecessary fetch results.
- Ensured callback-triggered refetches complete correctly after an initial fetch.
-
Release
- Included in a patch release of the query core package.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
A query kept its last retryer for life, and the settled promise holds that
fetch's raw result: a second full copy of the data once a refetch has been
structurally shared into state.data, and still held after reset() or removal.
coderabbitai
Bot
commented
Aug 9, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

📝 Walkthrough
Walkthrough
Query.fetch now releases the settled retryer when it remains current. Tests cover callback-triggered refetches and confirm that the query promise is cleared after both fetches settle. A patch changeset documents the behavior.
Changes
Settled retryer release
| Layer / File(s) |
Summary |
Clear settled retryers packages/query-core/src/query.ts |
Query.fetch stores the retryer locally, starts that instance, and clears #retryer after settlement when it still references the settled retryer. |
Validate retryer cleanup packages/query-core/src/__tests__/query.test.tsx, .changeset/release-settled-retryer.md |
Tests cover a callback-triggered refetch and verify that the query promise is cleared after both fetches resolve. The changeset records a patch release for @tanstack/query-core. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Possibly related PRs
- TanStack/query#11119: Both PRs modify
Query.fetch and query-core retryer behavior, but this PR releases settled retryers while that PR permits background retries.
Suggested reviewers: sukvvon
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name |
Status |
Explanation |
| Docstring Coverage |
✅ Passed |
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Title check |
✅ Passed |
The title clearly and concisely describes the primary change: releasing the query-core retryer after fetch settlement. |
| Description check |
✅ Passed |
The description covers the change, motivation, testing checklist, release impact, and generated changeset; the unselected test item is non-critical. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
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.
❤️ Share
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
nx-cloud
Bot
commented
Aug 17, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
View your CI Pipeline Execution ↗ for commit a4234c2
| Command |
Status |
Duration |
Result |
nx affected --targets=test:sherif,test:knip,tes... |
✅ Succeeded |
6m 24s |
View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded |
1m 51s |
View ↗ |
☁️ Nx Cloud last updated this comment at 2026-08-17 12:40:58 UTC
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
More templates
@tanstack/angular-query-experimental
npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11163
@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11163
@tanstack/lit-query
npm i https://pkg.pr.new/@tanstack/lit-query@11163
@tanstack/preact-query
npm i https://pkg.pr.new/@tanstack/preact-query@11163
@tanstack/preact-query-devtools
npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11163
@tanstack/preact-query-persist-client
npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11163
@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11163
@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11163
@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@11163
@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@11163
@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11163
@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11163
@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@11163
@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@11163
@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11163
@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11163
@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@11163
@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11163
@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11163
@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@11163
@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11163
@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11163
@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@11163
@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11163
commit: a4234c2
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
TkDodo
added a commit
that referenced
this pull request
Aug 18, 2026
* fix(query-core): release the retryer once a mutation settles
Mutation.execute() never cleared #retryer after settling, so the settled
retryer's promise kept that mutation's result, variables and context
reachable for as long as the MutationCache retained the Mutation. Mirror
the treatment Query.fetch() received in #11163, guarded by an identity
check so a mutation re-executed from a cache callback keeps its own
retryer.
Releasing the retryer alone would change continue(): a settled mutation
no longer has a retryer to continue, so it would fall through to
execute() and run the mutationFn a second time. Both internal callers
filter on state.isPaused and never reach a settled mutation, but
continue() is reachable directly, so the fallback is now gated on the
mutation still being pending -- the same condition execute() already uses
to detect a restored mutation.
Fixes #11216
* test(query-core): assert the settled retryer is actually released
The previous tests only guarded the continue() gating and passed on main
too, so they did not demonstrate the fix. continue() is the only reader
of #retryer outside execute(): while a settled retryer is still held it
hands back that retryer's promise, which resolves with the raw result it
closed over (or rejects with its error). Both new tests fail on main and
pass with the retryer released.
---------
Co-authored-by: Dominik Dorfmeister 🔮 <[email protected]>
ankurdotb
added a commit
to zama-ai/sdk
that referenced
this pull request
Aug 27, 2026
Reseeding alone wasn't enough this time - packages/react-sdk declares
an open ">=5" range for @tanstack/react-query, so a plain reinstall
left it pinned to whatever pnpm had cached, keeping wagmi split across
two @tanstack/query-core instances and breaking test-nextjs's build
with WagmiProviderNotFoundError. pnpm dedupe collapses it to one.
Separately, TanStack/query#11163 removes `promise` from a query
result's settled (success/error) state shape - it's no longer part of
the type once a fetch resolves, only while pending. The two balance
hook tests destructured it purely to exclude it from an inline
snapshot; since it's gone from the type entirely, drop the destructure
instead of asserting on a field that no longer exists. No production
code reads `.promise`.
Reviewers
TkDodo
TkDodo approved these changes
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|