fix(form-core): ignore aborted async form-level validation results #2350
Openofficial-burak(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/2350/headopened - @@ -1422,0 +1438,21 @@1438+ return undefined1439+ },1440+ },1441+ })1442+ const field = new FieldApi({1443+ form,1444+ name: 'name',1445+ })1446+ form.mount()1447+ field.mount()1448+1449+ field.setValue('slow-invalid')1450+ await vi.advanceTimersByTimeAsync(0)1451+ field.setValue('valid')1452+ await vi.advanceTimersByTimeAsync(50)1453+ expect(form.state.errors).toEqual([])1454+1455+ await vi.advanceTimersByTimeAsync(2000)1456+ expect(form.state.errors).toEqual([])1457+ expect(form.state.errorMap.onChange).toBeUndefined()1458+ vi.useRealTimers()
official-burak(GitHub profile, opens in a new tab) linked this to fix #2346
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
e512226c-b604-4089-9f20-2ac767b661a0📥 Commits
Reviewing files that changed from the base of the PR and between a0441e4e38969065c753046f68ec5954e8158ee9 and e7272c9eb99c1b581b9b7a8271aa3020f3c1ffa7.
📒 Files selected for processing: 1
packages/form-core/tests/FormApi.spec.ts🚧 Files skipped from review as they are similar to previous changes: 1
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
Form-level async validation now ignores results from aborted validation runs. A regression test verifies that a slower invalid validation cannot restore errors after a newer valid validation succeeds. A patch changeset documents the fix.
Changes: Stale async validation handling
packages/form-core/src/FormApi.ts,packages/form-core/tests/FormApi.spec.ts,.changeset/quiet-forms-ignore-stale.mdvalidateAsyncskips results when its validator controller is aborted. The regression test covers a slow invalid validation followed by a faster valid validation. The changeset declares a patch release for@tanstack/form-core.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: ⚪ Minimal · up to
e7272Aborted validation results no longer restore stale errors. No merge-blocking issue was identified.
Pre-merge checks:
5
pnpm test:prchecklist item is unchecked, but the description records targeted…#2346requires stale form-level async validation results to be ignored after a newer validation aborts the earlier run. The reviewed change adds an aborted-signal check after async validation se…FormApi, its focused regression test, and a@tanstack/form-corechangeset. These changes directly support issue#2346. No unrelated implementation or test changes are…Full details: Description check
Explanation
The description explains the problem, implementation, motivation, regression scenario, testing, and release impact. The
pnpm test:prchecklist item is unchecked, but the description records targeted local Vitest verification and the required changeset.Full details: Linked Issues check
Explanation
Issue
#2346requires stale form-level async validation results to be ignored after a newer validation aborts the earlier run. The reviewed change adds an aborted-signal check after async validation settles inFormApi.validateAsync. The regression test covers a slow invalid run followed by a faster valid run and verifies that the stale error does not update form errors orerrorMap.onChange. The changeset declares the required@tanstack/form-corepatch release.Full details: Out of Scope Changes check
Explanation
The pull request changes only
FormApi, its focused regression test, and a@tanstack/form-corechangeset. These changes directly support issue#2346. No unrelated implementation or test changes are shown.Full details: Docstring Coverage
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.
✨ 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.
❤️ Share