Skip to content

Commit

Permalink
fix(ext/abort): trigger AbortSignal events in correct order (denoland…
Browse files Browse the repository at this point in the history
…#20095)

This PR ensures that the original signal event is fired before any
dependent signal events.

---
The enabled tests fail on `main`:

```
assert_array_equals: Abort events fired in correct order expected property 0 to be 
"original-aborted" but got "clone-aborted" (expected array ["original-aborted", "clone-aborted"] 
got ["clone-aborted", "original-aborted"])
```
  • Loading branch information
marcosc90 authored Aug 8, 2023
1 parent 7ce8c2a commit 557b11b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
14 changes: 8 additions & 6 deletions ext/web/03_abort_signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,17 @@ class AbortSignal extends EventTarget {
return;
}
this[abortReason] = reason;
if (this[abortAlgos] !== null) {
for (const algorithm of new SafeSetIterator(this[abortAlgos])) {
algorithm();
}
this[abortAlgos] = null;
}
const algos = this[abortAlgos];
this[abortAlgos] = null;

const event = new Event("abort");
setIsTrusted(event, true);
this.dispatchEvent(event);
if (algos !== null) {
for (const algorithm of new SafeSetIterator(algos)) {
algorithm();
}
}
}

[remove](algorithm) {
Expand Down
8 changes: 2 additions & 6 deletions tools/wpt/expectation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4944,12 +4944,8 @@
"abort": {
"request.any.html": true,
"request.any.worker.html": true,
"general.any.html": [
"Clone aborts with original controller"
],
"general.any.worker.html": [
"Clone aborts with original controller"
],
"general.any.html": true,
"general.any.worker.html": true,
"cache.https.any.html": false,
"cache.https.any.worker.html": false
},
Expand Down

0 comments on commit 557b11b

Please sign in to comment.