You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Aborted async Standard Schema validation can overwrite newer form state #2346
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-form 1.33.5
@tanstack/form-core 1.33.5, installed by @tanstack/react-form
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.
Activity