Repository navigation
fix(query-persist-client-core): catch errors when persisting in 'persistQueryClientSubscribe' to prevent unhandled promise rejections, and log them in development - #11678
Conversation
…istQueryClientSubscribe' to prevent unhandled promise rejections, and log them in development
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Catch and verify save errors packages/query-persist-client-core/src/persist.ts, packages/query-persist-client-core/src/__tests__/persist.test.ts, .changeset/persist-subscribe-catch-save-errors.md |
Cache subscriptions use a shared callback that catches save errors and logs them outside production. Tests cover rejected persistence and dehydration errors. The changeset records the update. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: sukvvon
Merge Risk: 
Minimal · up to 88b67
-
No actionable issue remains before merge; complete the normal checks.
Security architecture risk: 
Low · up to a3231
-
Save failures are now handled instead of becoming unhandled rejections. The change does not alter which cache events trigger saves or who controls persisted storage, but production callers still receive no indication that a save failed.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The changed failure handling applies to saves initiated by each subscribed query client and its supplied persister. The evidence does not establish the storage provider's scope or a broader deployment boundary.
Trust Boundaries and Controls
- observed — The subscriber continues to filter cache events before invoking the existing save function. The change adds rejection handling rather than a new input route or storage authority.
Resilience and Maintainability Implications
- observed — Subscriber save errors are logged in development but have no subscriber-level reporting path in production. Restore errors follow a separate path that performs cleanup and rethrows.
-
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
The change satisfies issue
#11663.persistQueryClientSubscribenow handles rejectedpersistQueryClientSavecalls from query and mutation cache events. Development builds log the error and warning. Tests cover rejectedpersistClientcalls and exceptions fromdehydrateOptions, including repeated cache updates.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue
#11663. The source change handles save failures, the tests cover the required failure cases, and the changeset documents the same behavior. No unrelated product behavior is shown.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
|
Thanks for picking this up! The fix looks correct to me for both paths (a rejecting One thing that might be worth a maintainer's call: right now, a failed save in production at least surfaces as an unhandled rejection, which error trackers like Sentry pick up via That may well be the right tradeoff. I just wanted to point it out, since the restore side isn't silent in production (it calls |
|
Hey guys! Can you check this PR please? |
🦋 Changeset detectedLatest commit: 88b673d The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 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 88b673d
☁️ Nx Cloud last updated this comment at |
🎯 Changes
Fixes #11663.
persistQueryClientSubscribedropped the promise returned bypersistQueryClientSave, so a failingpersister.persistClient(e.g.QuotaExceededErrorfrom IndexedDB) or a throwingdehydrateOptionscallback caused an unhandled promise rejection on every cache update.The subscription now catches these errors and, in development, logs them with
console.error+console.warn, consistent with howpersistQueryClientRestorereports restore errors.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit
Summary by CodeRabbit