An AbortSignal.timeout signal aborts from its timer task
Date: 2026-12-04
Area: runtime
Supersedes in part: ADR 0104's "Because there is no timer task queue, an
AbortSignal.timeout() signal aborts at the moment the host observes its expiry"; ADR 0104's other decisions stand.
Related: ADR 0113, ADR 0214,
Fetch, Testing API,
#2595
Context
ADR 0104 made an AbortSignal.timeout(ms) signal abort when a read of its state (aborted, reason,
throwIfAborted()) or the fetch pump found its deadline passed, because GocciaScript had no timer task queue then. So
AbortSignal.timeout(0).aborted was true as soon as the signal was returned.
The DOM Standard (§ 3.2, AbortSignal.timeout(milliseconds)) runs "steps after a timeout" of milliseconds that
queue a global task on the timer task source, and that task signals abort with a TimeoutError DOMException.
Reading the signal's state never aborts it, so a signal is never aborted before the code that created it yields,
whatever its delay. Browsers, Node.js, Deno and Bun behave so. web-platform-tests' dom/abort/timeout.any.js checks it
("AbortSignal.timeout() returns a non-aborted signal"), and failed here.
ADR 0113 has since added the virtual timer queue, and AbortSignal.timeout already scheduled its abort there.
Decision
- An
AbortSignal.timeoutsignal aborts when its timer on the virtual timer queue runs, in due order with the other timers and, at the same due time, in the order they were started, as HTML's "run steps after a timeout" orders them. Reading its state does not abort it. - Its deadline on the monotonic clock still bounds the I/O of a
fetchthat uses it. When the fetch pump finds that deadline passed while a request waits on the signal, it aborts the signal then: that is the timer task on the wall clock the request's I/O keeps, and the event loop does not move the virtual clock while a request is in flight (ADR 0113). A request made with a signal whose deadline has passed but whose timer has not run is not refused atfetch(): it does not start, and the pump aborts the signal once the script yields, before any answer can come. - Its timer is the host's, not one of the timers fake timers replace, as in Vitest, where
AbortSignal.timeoutis not faked. While fake timers are installed it stays on the real timers' clock: installing or removing fake timers does not drop it, advancing the fake clock does not run it,getTimerCount()does not count it, and it runs once the run has nothing else to do, as a real timer would, or when the test that started it ends. - An exception its
abortlisteners throw is a timer callback's exception (ADR 0214).
Consequences
AbortSignal.timeout(0)returns a signal that is not aborted, and code can attach listeners and readabortedbefore it times out. The known failure for #2595 intests/web-platform-tests/helpers/expectations.jsis removed.- A script that busy-waits past a timeout's delay and then reads
abortedseesfalseuntil it yields. docs/testing-api.mdalready saidAbortSignal.timeout()is not faked; since the engine rewrite (#2187) its timer sat on the fake clock instead, so a fake-timer advance aborted it anduseFakeTimers()dropped it. Both now match the documentation.