- From: Nicolas Stepien <notifications@github.com>
- Date: Sun, 22 Mar 2026 13:01:45 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1461@github.com>
nstepien created an issue (whatwg/dom#1461)
### What is the issue with the DOM Standard?
When running synchronous code, `signal.aborted` does not become `true` after the expected timeout, `signal.throwIfAborted()` does not throw either.
This can be an issue in, for example, testing frameworks and lead to tasks never aborting if synchronous work keeps running.
I'd like to write code like this, but it's impossible as it stands:
```js
const signal = AbortSignal.timeout(500);
while (!signal.aborted) {
// perform work...
task(signal);
}
```
Repro code:
```js
const signal = AbortSignal.timeout(500);
const start = Date.now();
const timeout = start + 5000;
signal.addEventListener('abort', () => {
console.log('signal aborted');
});
while (Date.now() < timeout) {
// this should throw after 500ms
signal.throwIfAborted();
}
console.error('this log should be unreachable');
console.log('signal.aborted:', signal.aborted);
console.log('elapsed:', Date.now() - start);
signal.throwIfAborted();
```
Result:
<img width="279" height="121" alt="Image" src="https://github.com/user-attachments/assets/52bc10b8-15bb-4810-a4f8-2ca7ed205688" />
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1461
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/1461@github.com>
Received on Sunday, 22 March 2026 20:01:51 UTC