-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(query-core): ensure onMutate runs synchronously when cache config is undefined (#8724) #10066
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: 1e71dcb 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 |
📝 WalkthroughWalkthroughThis PR patches TanStack Query core to ensure the onMutate callback executes synchronously when mutationCache.config.onMutate is undefined. The fix replaces optional chaining with an explicit null check before awaiting, preventing unnecessary async wrapping when no cache-level onMutate handler exists. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
|
View your CI Pipeline Execution ↗ for commit 1e71dcb
☁️ Nx Cloud last updated this comment at |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10066 +/- ##
==========================================
+ Coverage 36.86% 42.68% +5.81%
==========================================
Files 245 172 -73
Lines 11102 8258 -2844
Branches 2091 1679 -412
==========================================
- Hits 4093 3525 -568
+ Misses 6484 4343 -2141
+ Partials 525 390 -135 🚀 New features to boost your workflow:
|
|
🎉 This PR has been released! Thank you for your contribution! |
🎯 Changes
onMutatenever actually runs synchronously #8724Previously, mutationCache.config.onMutate was always awaited using optional chaining (
await this.#mutationCache.config.onMutate?.()), which caused unnecessary async behavior even when the callback was undefined.Changed to conditional check: only await when onMutate is actually defined
Added regression test to verify synchronous execution when cache config is not provided
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.