Writing

AbortError: signal is aborted without reason, and why my error tracker saw it

By Mohamed Gado · · 4 min read

AbortError: signal is aborted without reason is the message Chrome and Edge give the error an AbortController creates when you call controller.abort() with no argument. Firefox and Safari give the same error a different text: The operation was aborted. On my Social Downloader it came from a timeout of my own, which my code caught. It still reached error tracking as unhandled, because a second promise chained off the same fetch had no catch. Passing abort() a reason, and filtering on the error's name rather than its text, fixes both halves.

What does "signal is aborted without reason" mean?#

abort() takes an optional reason. When you leave it out, the signal makes one for you: a DOMException named AbortError. Every fetch using that signal rejects with that exception.

const controller = new AbortController()
controller.abort()
 
console.log(controller.signal.reason.name)    // "AbortError"
console.log(controller.signal.reason.message) // Chrome: "signal is aborted without reason"
                                              // Firefox, Safari: "The operation was aborted."

The message means code in the page cancelled the request and gave no explanation. A network failure or a server refusal looks different (see the FAQ below).

Where mine came from: a timeout with no reason#

The downloader resolves a TikTok link two ways at once. The browser asks a public API directly, and the server resolves the same link in parallel. Whichever answers first wins. The browser call has a 6 second budget, written like this (trimmed to its shape):

async function resolveInBrowser(url) {
  const controller = new AbortController()
  const timer = setTimeout(() => controller.abort(), 6000)
  try {
    const response = await fetch(endpoint(url), { signal: controller.signal })
    if (!response.ok) return null
    return parse(await response.json())
  } catch {
    return null // timeout, offline, blocked: let the server answer
  } finally {
    clearTimeout(timer)
  }
}

The fetch and the .json() both sit inside the try, and the catch turns a timeout into null. On 27 November a visitor on Edge pasted a link to a TikTok photo post. The browser call ran out its 6 seconds, the server answered that it could not resolve the post, and the app showed that message, as designed. Four milliseconds later the error tracker recorded AbortError: signal is aborted without reason, marked as unhandled.

Why a caught AbortError can still show as unhandled#

The event had one stack frame, in one of my own bundles. I fetched that bundle from production and read the code at the frame's column. It was the controller.abort() inside the timer, which says less than it seems to. A DOMException records its stack when it is created, and abort() creates it. So the frame shows who cancelled the request, not who failed to handle the rejection. Every promise that rejects with this exception carries the same stack, wherever it was left unhandled.

My promise was handled, so the unhandled one had to be someone else's. Any script that patches window.fetch to watch requests can make a second promise from the original:

const originalFetch = window.fetch
window.fetch = function (...args) {
  const request = originalFetch.apply(this, args)
  request.then((response) => record(response)) // a second promise, never caught
  return request
}

The page gets request back and catches it. The .then() the wrapper made is a separate promise, and it rejects with the same AbortError. Nothing catches that one, so the browser fires unhandledrejection, and an error tracker listening for it reports the cancel as a crash. Browser extensions, analytics snippets and ad scripts all patch fetch this way. The stack does not say which one it was, and I could not find out. I could check that every path in my code caught it, and it did.

How to tell if the error is yours#

  1. Check how it was captured. An error tracker that marks it handled: false caught it from unhandledrejection or window.onerror, not from your own catch.
  2. Map the frame to code. Fetch the production bundle and read the code at the frame's line and column. If Cloudflare or a bot filter sits in front of the site, send a browser User-Agent, or you will get a challenge page instead of JavaScript.
  3. If the frame is an abort() call, read every promise that uses that signal. When each one is awaited inside a try, or has a .catch(), the unhandled copy is not yours.
  4. Read the session around it. Mine showed resolve_failed 4 ms before the exception: the cancel was the timeout doing its job.

How to fix it#

Give abort() a reason, and the rejection says what happened in every browser:

setTimeout(() => controller.abort(new DOMException('tikwm timed out', 'TimeoutError')), 6000)
 
// or let the platform do it:
fetch(url, { signal: AbortSignal.timeout(6000) }) // rejects with a TimeoutError

If you switch to TimeoutError, check every catch that tests error.name === 'AbortError'. A timeout no longer matches it, so code that treats a cancel as "the user changed their mind" will now treat a timeout as a failure. That is usually what you want, but check it on purpose.

For the error tracker, filter on the name, or on every engine's text. My error filter already dropped this cancel, but only in Safari's wording, The operation was aborted. Chrome's wording went straight through. A pattern for one engine's message misses the others, so match them together:

const BARE_ABORT = /^(DOMException: )?AbortError: (The operation was aborted|signal is aborted without reason)\.?$/i

If your tracker gives you the exception type as a separate field, filter on AbortError there and skip the text entirely.

I also wrote about the same class of noise from injected scripts in __gCrWeb and __firefox__ errors: code that isn't yours, reported as if it were.

FAQ#

Is "signal is aborted without reason" a network error?#

No. The request was cancelled by code in the page calling abort(). A network failure shows up as TypeError: Failed to fetch in Chrome, not as an AbortError.

Why does Firefox say "The operation was aborted" instead?#

The error is the same, a DOMException named AbortError. Each engine picks its own message text. Code that checks the name works everywhere, and code that checks the message works in one browser.

Should I report AbortError to my error tracker at all?#

Not a bare one. A cancel you started is expected behaviour. If you need to know how often a timeout fires, count it as a product event with the reason attached, and keep the error board for things that are actually broken.