Repository navigation
fix(form-core): set isValidating on every async validation run - #2423
drewsephski wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 945f846 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe async field-validation path now clears its debounce timeout slot when the timer fires. A regression test checks ChangesAsync field validation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to No merge-blocking issue is identified for the async-validation state fix. 🚥 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 |
🎯 Changes
Fixes #2372.
isValidatingis only set for the first async validation run. Every later run readsfalsewhile the validator is still pending.Root cause:
validateAsyncstores the debounce timer id infield.timeoutIds.validations[cause]and never clears it after the timer fires. The next run sees that id, treats it as a still-pending debounce, and callsendValidation()to compensate. That run already ended on its own, so the counter drops from 1 to 0 right afterstartValidation().Change: clear the slot when the timer fires. The compensation now only runs for a timer that was cleared before it fired.
Before, on
main, the new test fails on the second run:After:
pnpm exec vitest runinpackages/form-core: 18 files, 506 tests passpnpm test:pr(nx affected vsmain): pass, 145 tasks across 58 projectsI also checked two cases locally that are not in the test: a run superseded during its debounce still settles to
isValidating: false, and a second run started while the first validator is in flight staystrueuntil it resolves. Both end with_pendingValidationsCountat 0.✅ Checklist
pnpm test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit