v154 · abort reason
Timeout or user?
Both abort the same signal. One should be retried with backoff and reported as a network problem; the other should disappear silently, because the person already knows — they pressed the button. Telling them apart is what the reason is for.
Start a request, then end it two different ways
The request is composed from two signals with AbortSignal.any() — a user controller and an AbortSignal.timeout() — which is how real code wires this. Whichever fires first wins, and the handler has to work out which that was.
Nothing yet
Start a request and end it.
| source | value |
|---|
Log
- Nothing yet.
code path
const user = new AbortController();
const signal = AbortSignal.any([user.signal, AbortSignal.timeout(8000)]);
const response = await fetch(url, { signal });
try {
await response.text();
} catch (error) {
// A TimeoutError DOMException means the deadline; anything else is ours.
if (error?.name === "TimeoutError") retryWithBackoff();
else if (error?.code === "USER_CANCEL") dismissQuietly();
else throw error;
}
Both paths reject. Without the reason reaching response.text(), both rejections looked like AbortError and the only way to tell them apart was to keep a flag alongside the controller and hope it stayed in sync.