Skip to content
Source
Sign inSign up
TanStack/form

isValidating state updates to false before debounced async validation completes #2045

Send to my agent
OpenAdrianLea(GitHub profile, opens in a new tab) opened this issue 2 comments

Describe the bug

isValidating form state updates to false before debounced async validation completes. For example when the first async validation is resolving and a second async validation is triggered, once the first async validation resolves, isValidating is set to false even though the second async validation is still in flight.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-s6svm3er?file=src%2Findex.tsx

Steps to reproduce

  1. Type in "erro" in firstname
  2. Wait roughly half a second then add an "r" to make "error"
  3. isValidating disappears -> false
  4. After about half a second later the error appears

Expected behavior

As a user I expect, isValidating to be true whenever there is an async validation in flight. So the isValidating... text should not disappear before all async validations have completed. My specific use-case is showing a loading state while async validation is ongoing, however since the isValidating state becomes false early this can be misleading to users.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Google Chrome

TanStack Form adapter

react-form

TanStack Form version

1.28.3

TypeScript version

v5.8.3

Additional context

No response

  1. The bug is present without debouncing also, that is, even when onChangeAsyncDebounce is not present. In the given minimal Stackblitz example, bug is reproduced even after you remove the line 54

                  onChangeAsyncDebounceMs: 100,

    with the same instructions. I have added a video showing both the line removed and the bug reproduced.

    https://github.com/user-attachments/assets/93fb4645-0a19-4c20-8bb4-ac6977dda944

  2. LeCarbonator(GitHub profile, opens in a new tab) added labelsv2: needs investigation

  3. I reproduced the overlap on the published @tanstack/form-core@1.33.5, with debounce both disabled and enabled. Both checks had started; the first check ignored its aborted signal, then resolved while the second was still pending. At that point the original package exposed field.state.meta.isValidating === false.

    In this version, the fired debounce timer still has a stored handle. The next run treats it as a cancelled waiting timer and calls endValidation(); the earlier promise later calls endValidation() again. Clearing that handle at callback entry fixes this case without replacing the existing counter. I also found that the derived form state computes a validating value but does not publish it; the example includes that aggregate-state correction.

    I put a small version-pinned patch and runnable regression fixture here, including the matching TS source and both ESM/CJS runtime patches. After extracting its source ZIP:

    cd tanstack-validation-state
    npm ci --ignore-scripts
    npm run reproduce  # original package: expected assertion failures
    npm test           # patched copy: checks pass

    The checks cover both completion orders, debounce/no debounce, independent and linked fields, and form aggregate state. Verification patches a temporary copy and leaves the installed original untouched. This is Node FormApi/FieldApi evidence, not a browser UI test or a claim about every validation lifecycle.

    I saw the existing #2047; this is a separate workaround for the current published package, not a replacement PR or an upstream release. The guide includes the exact-version limits and application instructions in case the fixture is useful for investigating the issue.

Sign in to join this conversation.