GeezerVison is showing github.com — fix(react-query): retry useQuery().promise on error boundary reset by zaewc · Pull Request #10079 · TanStack/query
Conversation
zaewc
commented
Jan 29, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
🎯 Changes
Fixes #9978
Recreate the query promise when a retry transitions the query to fetching, ensuring useQuery().promise provides a fresh pending promise to Suspense.
Explicitly refetch errored queries on QueryErrorResetBoundary reset, even when useQuery is outside the ErrorBoundary.
Limit refetching to active and enabled queries to avoid unintended retries.
✅ 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
Release Notes
Bug Fixes
- Fixed
useQuery().promise behavior when used with QueryErrorResetBoundary to ensure queries retry correctly when the boundary resets, and promises are properly recreated for Suspense.
- Improved error boundary reset to explicitly refetch queries in errored state when a reset is triggered.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 29, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Note
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Use the following commands to manage reviews:
@coderabbitai resume to resume automatic reviews.
@coderabbitai review to trigger a single review.
Use the checkboxes below for quick actions:
- ▶️ Resume reviews
- 🔍 Trigger review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7e171586-2cf2-4b93-bb86-8eef87da862f
📥 Commits
Reviewing files that changed from the base of the PR and between d4cd23a and 714297c.
📒 Files selected for processing (1)
.changeset/retry-promise-on-error-boundary-reset.md
✅ Files skipped from review due to trivial changes (1)
- .changeset/retry-promise-on-error-boundary-reset.md
📝 Walkthrough
Walkthrough
Fixes useQuery().promise not retrying after QueryErrorResetBoundary reset. Thenables in QueryObserver are now tagged with a non-enumerable queryHash. QueryErrorResetBoundary gains a scoped query hash registry with a register method and an enhanced reset that refetches errored registered queries. useBaseQuery registers the query hash when suspense or prefetch-in-render is active. Two helper exports (getQueryHash, useTrackQueryHash) are added and exercised in new tests.
Changes
QueryErrorResetBoundary retry fix for useQuery().promise
| Layer / File(s) |
Summary |
Thenable hash tagging in queryObserver packages/query-core/src/queryObserver.ts |
Adds PromiseWithHash<T> type and tagThenable helper; attaches a non-enumerable queryHash to observable promise fields; recreates thenable when fetchStatus === 'fetching' on a rejected result. |
QueryErrorResetBoundary registry and reset enhancement packages/react-query/src/QueryErrorResetBoundary.tsx, packages/react-query/src/index.ts |
Extends QueryErrorResetBoundaryValue with register(queryHash); implements a Set<string> registry via useRef; overrides reset to refetch active errored queries whose hashes were registered; exports getQueryHash and useTrackQueryHash helpers. |
Registration wiring in useBaseQuery packages/react-query/src/useBaseQuery.ts |
Calls errorResetBoundary.register(queryHash) before cache entry creation when experimental_prefetchInRender or suspense is enabled. |
Tests and changeset packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx, packages/react-query/src/__tests__/useQuery.promise.test.tsx, .changeset/retry-promise-on-error-boundary-reset.md |
Adds "Scoped Registry" test suite covering boundary isolation, registry clearing, StrictMode double-registration, and useTrackQueryHash integration; adds test for retry via QERB when useQuery is outside the boundary subtree; adds patch changeset. |
Sequence Diagram(s)
sequenceDiagram
participant Page as Page (useQuery outside boundary)
participant useBaseQuery
participant QERB as QueryErrorResetBoundary
participant queryObserver as QueryObserver
participant Child as MySubComponent (React.use)
Page->>useBaseQuery: render with suspense/prefetchInRender
useBaseQuery->>QERB: register(queryHash)
useBaseQuery->>queryObserver: createResult()
queryObserver-->>useBaseQuery: result.promise tagged with queryHash (PromiseWithHash)
Page->>Child: pass promise
Child->>Child: React.use(promise) → throws on error
Note over Page,Child: Error boundary catches, shows retry button
Page->>QERB: reset() triggered by user
QERB->>QERB: collect registered hashes, clear registry
QERB->>queryObserver: client.refetchQueries(predicate: errored & registered)
queryObserver->>queryObserver: recreate pending thenable (tagged with queryHash)
queryObserver-->>Child: fresh pending promise → Suspense re-suspends
queryObserver-->>Child: resolves with data
Loading
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Poem
🐇 Hoppity hop, the boundary broke,
A promise got lost in rejection's smoke.
We tagged the thenable, registered the hash,
Reset the boundary — no longer a crash!
Now retry buttons work, every time,
Fresh pending promises, truly sublime. ✨
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name |
Status |
Explanation |
| Title check |
✅ Passed |
The title 'fix(react-query): retry useQuery().promise on error boundary reset' is concise, specific, and directly describes the main change addressing issue #9978. |
| Description check |
✅ Passed |
The description follows the provided template, includes the linked issue reference, explains the fix clearly, and has all required checklist items completed. |
| Linked Issues check |
✅ Passed |
Changes comprehensively address issue #9978: promise recreation on retry [queryObserver.ts], explicit refetch on boundary reset [QueryErrorResetBoundary.tsx], selective refetching [useBaseQuery.ts], plus extensive test coverage validating the fix. |
| Out of Scope Changes check |
✅ Passed |
All changes are directly scoped to fixing issue #9978: core promise tagging, boundary registry tracking, hook/helper exports, test coverage, and proper documentation via changeset. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ 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 and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
nx-cloud
Bot
commented
Jan 29, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
View your CI Pipeline Execution ↗ for commit 208d0ed
| Command |
Status |
Duration |
Result |
nx affected --targets=test:sherif,test:knip,tes... |
✅ Succeeded |
3m 18s |
View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded |
1s |
View ↗ |
☁️ Nx Cloud last updated this comment at 2026-04-08 23:41:44 UTC
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pkg-pr-new
Bot
commented
Jan 29, 2026
•
edited
Loading
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@10079
@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10079
@tanstack/preact-query
npm i https://pkg.pr.new/@tanstack/preact-query@10079
@tanstack/preact-query-devtools
npm i https://pkg.pr.new/@tanstack/preact-query-devtools@10079
@tanstack/preact-query-persist-client
npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10079
@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10079
@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10079
@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@10079
@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@10079
@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10079
@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10079
@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@10079
@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@10079
@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10079
@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10079
@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@10079
@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10079
@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10079
@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@10079
@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10079
@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10079
@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@10079
@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10079
commit: 208d0ed
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/react-query/src/QueryErrorResetBoundary.tsx`:
- Around line 26-33: The predicate used in client?.refetchQueries incorrectly
treats observer.options.enabled functions as truthy; update the predicate to
resolve the enabled state using resolveEnabled from query-core (same approach as
in query.ts:270) so the check becomes something like resolving
observer.options.enabled against the query and comparing to !== false before
counting it as enabled; modify the predicate passed to refetchQueries where
query, observer, and observer.options.enabled are referenced and import/use
resolveEnabled to properly evaluate callback-based enabled options.
🧹 Nitpick comments (1)
packages/react-query/src/QueryErrorResetBoundary.tsx (1)
61-62: Consider potential stale closure with QueryClient.
The useState initializer captures the client reference at mount time. While the QueryClient instance is typically stable throughout an app's lifecycle, if it were to change (e.g., during testing or in edge cases), the value.reset() would continue using the original client.
This is likely acceptable given typical usage patterns, but worth noting for awareness.
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.
sentry
Bot
commented
Jan 29, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.74%. Comparing base (ed5e5fc) to head (00af302).
Additional details and impacted files

@@ Coverage Diff @@
## main #10079 +/- ##
==========================================
+ Coverage 36.87% 42.74% +5.87%
==========================================
Files 245 172 -73
Lines 11103 8267 -2836
Branches 2083 1687 -396
==========================================
- Hits 4094 3534 -560
+ Misses 6484 4343 -2141
+ Partials 525 390 -135
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx`:
- Around line 1063-1068: TrackedChild currently passes a raw string to
useTrackQueryHash (via queryClient.getQueryCache().build(...).queryHash), but
getQueryHash only registers objects; update TrackedChild to pass an object
instead (for example call useTrackQueryHash({ queryHash: hash }) or pass the
original query descriptor like useTrackQueryHash({ queryKey: key })) so the hook
registers the tracked query; change the call site in TrackedChild where
useTrackQueryHash(...) is invoked.
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.
…t.tsx
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/react-query/src/__tests__/QueryResetErrorBoundary.test.tsx`:
- Around line 1063-1072: There is a stray closing brace after the TrackedChild
component that breaks parsing; remove the extra `}` following the TrackedChild
function declaration so the component's braces match correctly (locate the
TrackedChild function that calls queryClient.getQueryCache().build(...) and
useTrackQueryHash and delete the superfluous closing brace to restore valid
syntax).
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
after reading your feedback, I had a new idea and reworked the approach. I've updated the logic to use a registry-based tracking system with queryHash-tagged promises.
Could you please take another look ?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts:
# packages/query-core/src/queryObserver.ts
The function was renamed to resolveQueryBoolean on main; the PR's added
export survived the merge and pointed at a non-existent symbol. Nothing
imports it externally, so remove it to match main's public surface.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
TkDodo
Awaiting requested review from TkDodo
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|