Skip to content

AbortController Fetch Already Aborted

Quick summary

You aborted the controller before or during fetch — the promise rejects with AbortError and the response is never received.

Why this happens

  • Calling controller.abort() before the fetch promise settles

  • Reusing a single AbortController for multiple sequential fetches

  • Aborting on unmount but the fetch already completed and was aborted again

Minimal example

✗ Broken code
const ctrl = new AbortController();
ctrl.abort();
fetch('/api', { signal: ctrl.signal })
  .catch(err => console.error(err)); // AbortError — already aborted
✓ Fixed code
const ctrl = new AbortController();
fetch('/api', { signal: ctrl.signal })
  .catch(err => { if (err.name !== 'AbortError') console.error(err); });
// ctrl.abort() only when you actually want to cancel

Aborting before fetch rejects immediately with AbortError. Only abort when cancellation is intended, and ignore AbortError in the catch handler.

How to diagnose

  • Check err.name === 'AbortError' in the catch block

  • Log the signal.aborted value before calling fetch

  • Ensure each fetch gets a fresh AbortController if needed

How to fix

  • Create a new AbortController for each fetch that may be aborted independently

  • Check signal.aborted before calling fetch and skip if already aborted

  • Ignore AbortError in the catch block since it is expected

How to prevent

  • Use one controller per fetch lifecycle

  • Always handle AbortError gracefully in fetch catch blocks

Related Resources

Related Glossary

Related Lessons

  • HTTP

    Learn about fetch and AbortController.

← Back to language