-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix unhandled promise rejections during de/rehydration of pending queries #9752
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
Conversation
🦋 Changeset detectedLatest commit: 6960735 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 |
View your CI Pipeline Execution ↗ for commit 6960735
☁️ Nx Cloud last updated this comment at |
WalkthroughAdds a shared dehydration promise with redaction and a no-op catch to prevent unhandled rejections for pending queries, applies a no-op catch during rehydration fetches, updates imports, removes test listeners for unhandledRejection, and adds a changeset for patch bumps to @tanstack/react-query and @tanstack/query-core. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant QueryClient
participant Serializer as Serializer/Dehydrate
participant Redactor as Error Redactor
participant Logger
rect rgba(230,245,255,0.5)
note over App,QueryClient: Dehydrate pending queries (changed)
App->>QueryClient: dehydrate()
QueryClient->>Serializer: serialize pending query
Serializer->>Redactor: redact non-permitted errors
Redactor-->>Serializer: redacted error/result
Serializer-->>QueryClient: shared promise (with catch(noop))
QueryClient-->>App: DehydratedState (refs shared promise)
end
Note right of Logger: In non-production, log redacted errors
sequenceDiagram
autonumber
participant App
participant Hydration as HydrationBoundary
participant QueryClient
participant Fetch as Pending Fetch
rect rgba(230,255,230,0.5)
note over App,Hydration: Rehydrate pending queries (changed)
App->>Hydration: useDehydratedState(DehydratedState)
Hydration->>QueryClient: rehydrate()
QueryClient->>Fetch: resume/trigger pending query fetch
Fetch-->>QueryClient: Promise
QueryClient->>Fetch: attach catch(noop) to avoid unhandled rejection
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🧰 Additional context used🧬 Code graph analysis (1)packages/query-core/src/hydration.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9752 +/- ##
===========================================
+ Coverage 45.53% 59.78% +14.24%
===========================================
Files 196 125 -71
Lines 8327 5555 -2772
Branches 1894 1516 -378
===========================================
- Hits 3792 3321 -471
+ Misses 4093 1935 -2158
+ Partials 442 299 -143 🚀 New features to boost your workflow:
|
🎯 Changes
This PR adds two
.catch(noop)
to handle previously unhandled promise rejection errors when dehydrating and hydrating promises, which happens when de/rehydrating pending queries.The errors themselves are still propagated to the query client like before, this is just handling two extraneous promises we are not using the output of.
There are still other active bugs stemming from how we use
query.fetch
to set up a retryer. I took a stab at adding a newquery.createRetryer
method and use that instead, but turns out this was a bigger refactor so I wanted to get this quick fix out quickly before revisiting that.✅ Checklist
pnpm run test:pr
.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests
Chores