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
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: TanStack/query/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesPersistence save error handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Cache-triggered persistence failures are handled, and no merge-blocking issue is identified. The change is ready for normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to 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 Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
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? |
🎯 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