Menu

1 / 4

Your Fetch Succeeded. Your AbortSignal.timeout Still Went Off.

JavaScript in Plain English - Medium·Ferid Brković·about 20 hours ago
#dF2VHzty
Reading 0:00
15s threshold

Member-only story

Your Fetch Succeeded. Your AbortSignal.timeout Still Went Off.

AbortSignal.any makes cancellation easy to combine and easy to misread. Here is how to tell who stopped a request.

Ferid Brković

6 min read9 hours ago

--

Press enter or click to view image in full size

Picture a download button with two ways to stop it: the user can press Cancel, and the request gives up after a few seconds. AbortSignal.any() lets you hand both to fetch as one signal. You attach an abort listener that shows "This is taking too long" when the timeout wins, ship it, and it works.

Then a support ticket arrives. The file downloaded fine, and a few seconds later the page said it had timed out.

Nothing is wrong with the browser. The timeout signal did exactly what the specification says it does. This article shows why the message appears, how to stop it, and how to tell reliably whether the user or the clock stopped a request.

The pattern that looks finished

Here is the version most code starts with.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.