GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(query-core): release the retryer once a fetch settles by codebytere-ant · Pull Request #11163 · TanStack/query

Conversation

@codebytere-ant

@codebytere-ant codebytere-ant commented Aug 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

🎯 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.

All reactions
@codebytere-ant
fix(query-core): release the retryer once a fetch settles
d504d4d
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

coderabbitai Bot commented Aug 9, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

MILLERMARRU

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TkDodo
Merge branch 'main' into release-settled-retryer
a4234c2
@nx-cloud

nx-cloud Bot commented Aug 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

TkDodo
TkDodo approved these changes Aug 17, 2026
View reviewed changes
@pkg-pr-new

pkg-pr-new Bot commented Aug 17, 2026

Copy link
Copy Markdown
More templates

  • @tanstack/query-example-angular-auto-refetching
  • @tanstack/query-example-angular-basic
  • @tanstack/query-example-angular-basic-persister
  • @tanstack/query-example-angular-devtools-panel
  • @tanstack/query-example-angular-infinite-query-with-max-pages
  • @tanstack/query-example-angular-optimistic-updates
  • @tanstack/query-example-angular-pagination
  • @tanstack/query-example-angular-query-options-from-a-service
  • @tanstack/query-example-angular-router
  • @tanstack/query-example-angular-rxjs
  • @tanstack/query-example-angular-simple
  • @tanstack/query-example-lit-basic
  • @tanstack/query-example-lit-pagination
  • @tanstack/query-example-lit-ssr
  • @tanstack/query-example-preact-simple
  • @tanstack/query-example-react-algolia
  • @tanstack/query-example-react-auto-refetching
  • @tanstack/query-example-react-basic
  • @tanstack/query-example-react-basic-graphql-request
  • @tanstack/query-example-chat
  • @tanstack/query-example-react-default-query-function
  • @tanstack/query-example-react-devtools-panel
  • @tanstack/query-example-eslint-legacy
  • @tanstack/query-example-eslint-plugin-demo
  • @tanstack/query-example-react-infinite-query-with-max-pages
  • @tanstack/query-example-react-load-more-infinite-scroll
  • @tanstack/query-example-react-nextjs
  • @tanstack/query-example-react-nextjs-app-prefetching
  • @tanstack/query-example-nextjs-suspense-streaming
  • @tanstack/query-example-react-offline
  • @tanstack/query-example-react-optimistic-updates-cache
  • @tanstack/query-example-react-optimistic-updates-ui
  • @tanstack/query-example-react-pagination
  • @tanstack/query-example-react-playground
  • @tanstack/query-example-react-prefetching
  • @tanstack/query-example-react-react-native
  • @tanstack/query-example-react-router
  • @tanstack/query-example-react-rick-morty
  • @tanstack/query-example-react-shadow-dom
  • @tanstack/query-example-react-simple
  • @tanstack/query-example-react-star-wars
  • @tanstack/query-example-react-suspense
  • @tanstack/query-example-solid-astro
  • @tanstack/query-example-solid-basic
  • @tanstack/query-example-solid-basic-graphql-request
  • @tanstack/query-example-solid-default-query-function
  • @tanstack/query-example-solid-offline
  • @tanstack/query-example-solid-simple
  • @tanstack/query-example-solid-start-streaming
  • @tanstack/query-example-svelte-auto-refetching
  • @tanstack/query-example-svelte-basic
  • @tanstack/query-example-svelte-load-more-infinite-scroll
  • @tanstack/query-example-svelte-optimistic-updates
  • @tanstack/query-example-svelte-playground
  • @tanstack/query-example-svelte-simple
  • @tanstack/query-example-svelte-ssr
  • @tanstack/query-example-svelte-star-wars
  • @tanstack/query-example-vue-2.6-basic
  • @tanstack/query-example-vue-2.7-basic
  • @tanstack/query-example-vue-basic
  • @tanstack/query-example-vue-dependent-queries
  • @tanstack/query-example-vue-nuxt3
  • @tanstack/query-example-vue-persister
  • @tanstack/query-example-vue-simple

@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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TkDodo
TkDodo merged commit 4a9bef6 into TanStack:main Aug 17, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Aug 17, 2026
ci: Version Packages #11206
Merged
@MILLERMARRU MILLERMARRU mentioned this pull request Aug 18, 2026
Mutation.execute() never releases #retryer after settling, unlike Query.fetch() after #11163 #11216
Closed
@iamshahid1997 iamshahid1997 mentioned this pull request Aug 18, 2026
fix(query-core): release the retryer once a mutation settles #11218
Merged
3 of 4 tasks
@Gujiassh Gujiassh mentioned this pull request Aug 18, 2026
fix(query-core): release the mutation retryer once execute settles #11219
Closed
TkDodo added a commit that referenced this pull request Aug 18, 2026
@iamshahid1997 @TkDodo
fix(query-core): release the retryer once a mutation settles (#11218)
5981771
* 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]>
@coderabbitai coderabbitai Bot mentioned this pull request Aug 18, 2026
fix(query-core): don't reject imperative fetch with CancelledError when a superseding fetch is started #11061
Closed
3 tasks done
ankurdotb added a commit to zama-ai/sdk that referenced this pull request Aug 27, 2026
@ankurdotb
fix: dedupe lockfile and update balance tests for TanStack Query 5.102.2
0a08434
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`.
@ankurdotb ankurdotb mentioned this pull request Aug 27, 2026
chore(deps): bump the test-apps group across 2 directories with 1 update zama-ai/sdk#656
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@TkDodo TkDodo TkDodo approved these changes
+1 more reviewer
@MILLERMARRU MILLERMARRU MILLERMARRU left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

3 participants

@codebytere-ant @TkDodo @MILLERMARRU
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.