-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(query-core): avoid throwing promise errors when data exists #10025
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: cf7059e The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 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 |
📝 WalkthroughWalkthroughThe PR fixes error boundary behavior in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-11-22T09:06:05.219ZApplied to files:
🧬 Code graph analysis (1)packages/react-query/src/__tests__/useQuery.promise.test.tsx (1)
🔇 Additional comments (6)
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. Comment |
🎯 Changes
Fixes: #9938
experimental_prefetchInRenderpromise rejection behavior with Suspense defaults.useInfiniteQuery).🧠 Motivation
useSuspenseInfiniteQueryonly throws to the Error Boundary when there is no data to show. However,useInfiniteQuerycombined withexperimental_prefetchInRenderwas rejecting the promise even when data existed (e.g. page 2 fetch errors), which made Error Boundary appear unexpectedly. This change makes both paths consistent.🔧 Implementation Notes
packages/query-core/src/queryObserver.ts.packages/react-query/src/__tests__/useQuery.promise.test.tsxto ensure refetch/page errors with existing data do not throw to Error Boundary.🧪 Testing
✅ Checklist
📷 Optional Evidence
Before: fetch next page error triggers Error Boundary

After: fetch next page error does not trigger Error Boundary;

isFetchNextPageError: trueis shownSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.