Aborted async Standard Schema validation can overwrite newer form state
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
Describe the bug
A form-level onChangeAsync Standard Schema validator can apply a stale result after a newer validation has aborted it.
When a new async validation starts, TanStack Form aborts the previous validation's AbortController. However, Standard Schema validators receive the value rather than TanStack Form's AbortSignal.
A Zod async refinement therefore cannot observe the cancellation and may continue running.
After the older validator resolves, TanStack Form applies its result without checking the signal again. The stale result can consequently restore an error after a newer validation has already
accepted the current value.
This is related to #1457, but this reproduction uses only one form-level async Standard Schema validator. It does not combine synchronous and asynchronous validators.
Tested with:
@tanstack/react-form1.33.5@tanstack/form-core1.33.5, installed by@tanstack/react-form- Zod 4.4.3
Your minimal, reproducible example
https://stackblitz.com/edit/vitejs-vite-gep72csm?file=src%2FApp.tsx
Steps to reproduce
- Open the reproduction.
- Click Reproduce once. The example automatically starts a delayed validation for slow-invalid, changes the value to valid, and then lets the older validation finish.
- Confirm that the current field value is valid.
- Observe that the field nevertheless contains Stale validation result from the previous slow-invalid value.
- Reload the page to repeat the reproduction; the button is deliberately disabled after the first run.
Expected behavior
The newer validation for valid aborts the pending validation for slow-invalid. When the older validation eventually finishes, its result should be ignored.
The current value should remain valid, and the field should have no validation errors.
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
- OS: Windows
- Browser: FF 153.0.3
TanStack Form adapter
None
TanStack Form version
1.33.5
TypeScript version
6.0.2
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in src/App.tsx from the linked StackBlitz example and run the listed steps to observe the stale error. Trace form-level async Standard Schema validation in the repository; done means an older validation result is ignored after a newer validation accepts the current value, leaving no validation errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100