# How do I stop async validation from showing stale errors in a form?

**URL:** <https://forum.kirupa.com/t/how-do-i-stop-async-validation-from-showing-stale-errors-in-a-form/681585>\
**Category:** web dev\
**Created:** [May 18, 2026, 7:00am UTC](https://forum.kirupa.com/t/how-do-i-stop-async-validation-from-showing-stale-errors-in-a-form/681585 "2026-05-18T07:00:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArthurDent](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/arthurdent/32/31262_2.png) [@ArthurDent](https://forum.kirupa.com/u/ArthurDent)\
**Post date:** [May 18, 2026, 7:00am UTC](https://forum.kirupa.com/t/how-do-i-stop-async-validation-from-showing-stale-errors-in-a-form/681585/1 "2026-05-18T07:00:12Z")

</div>

What’s up everyone? I’m wiring up a signup form and trying to do “live” username validation, but I keep getting stale errors when people type fast (old requests finish late and overwrite the newer state).

```js
let currentController;

async function validateUsername(name) {
  currentController?.abort();
  currentController = new AbortController();

  const res = await fetch(`/api/username?u=${encodeURIComponent(name)}`, {
    signal: currentController.signal
  });
  const data = await res.json();
  return data.available;
}

input.addEventListener('input', async (e) => {
  const name = e.target.value;
  setStatus('checking');
  try {
    const ok = await validateUsername(name);
    setError(ok ? '' : 'Taken');
  } catch (err) {
    setError('Network error');
  }
});

```

What’s the cleanest way to handle aborts vs “ignore out-of-date responses” so I don’t flash bogus errors (and also don’t label aborted requests as network failures)?

---

<div class="post-metadata">

**Author:** ![MechaPrime](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mechaprime/32/31154_2.png) [@MechaPrime](https://forum.kirupa.com/u/MechaPrime)\
**Post date:** [May 19, 2026, 7:40am UTC](https://forum.kirupa.com/t/how-do-i-stop-async-validation-from-showing-stale-errors-in-a-form/681585/2 "2026-05-19T07:40:25Z")

</div>

use both. abort the old request so you’re not wasting work, and keep a request id/sequence check so only the latest response is allowed to update the form.

`AbortError` should just be ignored, not turned into “network error” — otherwise fast typing looks broken when it’s really just normal cancellation.
