GeezerVison is showing github.com — fix(preact-query): allow retryOnMount when throwOnError is function by S-jooyoung · Pull Request #11166 · TanStack/query
Conversation
S-jooyoung
commented
Aug 10, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
🎯 Changes
Fixes #11165.
Ports #9338 to preact-query. react-query's ensurePreventErrorBoundaryRetry evaluates a function-form throwOnError against the query's actual error before disabling retryOnMount; preact-query's copy still treats any function as truthy, so throwOnError: () => false (or a predicate returning false for the current error) wrongly prevents an errored query from refetching on remount.
✅ 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).
🤖 Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Improved retry-on-mount behavior when
throwOnError is configured as a function.
- Failed queries now correctly retry on remount when the function allows it.
- Error handling evaluates the actual query error before deciding whether retries should be prevented.
- Consistent behavior is now applied across individual and multiple-query usage.
- Tests
- Added coverage for retrying, preventing retries, and evaluating specific error messages during remounts.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Ports TanStack#9338 to preact-query: ensurePreventErrorBoundaryRetry now
receives the cached query and evaluates a function-form throwOnError
against the actual error before setting retryOnMount = false, instead
of treating any function as truthy. Includes the regression tests
from TanStack#9338, two of which fail on current main.
Fixes TanStack#11165
Co-Authored-By: Claude Fable 5 <[email protected]>
coderabbitai
Bot
commented
Aug 10, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8eb5203a-254e-4ec4-b7ec-e8b01a079364
📥 Commits
Reviewing files that changed from the base of the PR and between 3c79861 and e060a89.
📒 Files selected for processing (5)
.changeset/preact-retry-on-mount-throw-on-error.md
packages/preact-query/src/__tests__/useQuery.test.tsx
packages/preact-query/src/errorBoundaryUtils.ts
packages/preact-query/src/useBaseQuery.ts
packages/preact-query/src/useQueries.ts
🚧 Files skipped from review as they are similar to previous changes (5)
- .changeset/preact-retry-on-mount-throw-on-error.md
- packages/preact-query/src/useQueries.ts
- packages/preact-query/src/errorBoundaryUtils.ts
- packages/preact-query/src/useBaseQuery.ts
- packages/preact-query/src/tests/useQuery.test.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough
Preact Query now evaluates functional throwOnError values against the cached query error before disabling retryOnMount. Cached query retrieval is reused across error-boundary and prefetch handling. Tests cover false, true, and error-specific predicates.
Changes
Preact retry-on-mount error handling
| Layer / File(s) |
Summary |
Resolve throwOnError from cached query state packages/preact-query/src/errorBoundaryUtils.ts, packages/preact-query/src/useBaseQuery.ts |
ensurePreventErrorBoundaryRetry receives the cached query and resolves functional throwOnError values with the actual query error. useBaseQuery reuses the cached query for error-boundary checks and prefetch promises. |
Wire query hooks and validate retry behavior packages/preact-query/src/useQueries.ts, packages/preact-query/src/__tests__/useQuery.test.tsx, .changeset/preact-retry-on-mount-throw-on-error.md |
useQueries passes each cached query to error-boundary handling. Tests cover functional predicates that return false, return true, or inspect the actual error. The changeset records the patch. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: ⚪ Minimal · up to e060a
This change corrects retry-on-remount behavior for function-based error handling and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review.
Sequence Diagram(s)
sequenceDiagram
participant useBaseQuery
participant QueryCache
participant ensurePreventErrorBoundaryRetry
participant shouldThrowError
useBaseQuery->>QueryCache: Retrieve cached query by queryHash
useBaseQuery->>ensurePreventErrorBoundaryRetry: Pass options, reset boundary, and query
ensurePreventErrorBoundaryRetry->>shouldThrowError: Evaluate throwOnError with query.error and query
shouldThrowError-->>ensurePreventErrorBoundaryRetry: Return resolved boolean
ensurePreventErrorBoundaryRetry->>useBaseQuery: Apply retryOnMount prevention when resolved value is true
Loading
Possibly related PRs
Suggested reviewers: tkdodo
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name |
Status |
Explanation |
| Title check |
✅ Passed |
The title clearly identifies the main fix: allowing retryOnMount when functional throwOnError returns false. |
| Description check |
✅ Passed |
The description includes the required changes, checklist, release impact, motivation, implementation details, and test coverage. |
| Linked Issues check |
✅ Passed |
The changes satisfy issue #11165 by evaluating functional throwOnError against the actual error and adding matching regression tests. |
| Out of Scope Changes check |
✅ Passed |
The modified source files, tests, and changeset directly support the linked issue and stated parity objectives. |
| Docstring Coverage |
✅ Passed |
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✨ 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.
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
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/preact-query/src/errorBoundaryUtils.ts`:
- Around line 30-33: The throwOnError logic should evaluate the predicate for
every query in an error state, including failures with falsy values such as 0,
empty string, or null. Replace the query.state.error truthiness guard with the
query’s established error-status check, preserving direct option handling for
non-error states, and add coverage for a falsy rejected value.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 9e770acb-1a84-48ad-bfad-7ea1ea56d651
📥 Commits
Reviewing files that changed from the base of the PR and between 46d7f02 and 8948869.
📒 Files selected for processing (5)
.changeset/preact-retry-on-mount-throw-on-error.md
packages/preact-query/src/__tests__/useQuery.test.tsx
packages/preact-query/src/errorBoundaryUtils.ts
packages/preact-query/src/useBaseQuery.ts
packages/preact-query/src/useQueries.ts
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.
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
nx-cloud
Bot
commented
Aug 20, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
View your CI Pipeline Execution ↗ for commit e060a89
| Command |
Status |
Duration |
Result |
nx affected --targets=test:sherif,test:knip,tes... |
✅ Succeeded |
3m 49s |
View ↗ |
nx run-many --target=build --exclude=examples/*... |
✅ Succeeded |
8s |
View ↗ |
☁️ Nx Cloud last updated this comment at 2026-08-20 08:53:23 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@11166
@tanstack/eslint-plugin-query
npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11166
@tanstack/lit-query
npm i https://pkg.pr.new/@tanstack/lit-query@11166
@tanstack/preact-query
npm i https://pkg.pr.new/@tanstack/preact-query@11166
@tanstack/preact-query-devtools
npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11166
@tanstack/preact-query-persist-client
npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11166
@tanstack/query-async-storage-persister
npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11166
@tanstack/query-broadcast-client-experimental
npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11166
@tanstack/query-core
npm i https://pkg.pr.new/@tanstack/query-core@11166
@tanstack/query-devtools
npm i https://pkg.pr.new/@tanstack/query-devtools@11166
@tanstack/query-persist-client-core
npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11166
@tanstack/query-sync-storage-persister
npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11166
@tanstack/react-query
npm i https://pkg.pr.new/@tanstack/react-query@11166
@tanstack/react-query-devtools
npm i https://pkg.pr.new/@tanstack/react-query-devtools@11166
@tanstack/react-query-next-experimental
npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11166
@tanstack/react-query-persist-client
npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11166
@tanstack/solid-query
npm i https://pkg.pr.new/@tanstack/solid-query@11166
@tanstack/solid-query-devtools
npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11166
@tanstack/solid-query-persist-client
npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11166
@tanstack/svelte-query
npm i https://pkg.pr.new/@tanstack/svelte-query@11166
@tanstack/svelte-query-devtools
npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11166
@tanstack/svelte-query-persist-client
npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11166
@tanstack/vue-query
npm i https://pkg.pr.new/@tanstack/vue-query@11166
@tanstack/vue-query-devtools
npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11166
commit: e060a89
|
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.
Reviewers
TkDodo
TkDodo approved these changes
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.
|