Skip to content

Commit

Permalink
Mark dependent abort signals as aborted before firing events
Browse files Browse the repository at this point in the history
The assert in 4.2.1 of "create a dependent abort signal" fails when
creating a dependent signal while dispatching abort events or running
abort algorithms if abort had not yet been propagated to one of the
sources.

This fix splits "signal abort" into two phases: first, set the abort
reason on the signal being aborted and all of its unaborted dependents;
next, run the abort algorithms and dispatch events for the signal and
those same dependents. Note that:
 1. Dependent signals do not themselves have dependent signals, which
    means it's unnecessary to recursively call "signal abort"
 2. This approach retains the existing event dispatch order, while
    ensuring the abort state is synced before any JS runs

This fixes #1293.
  • Loading branch information
shaseley authored Aug 21, 2024
1 parent 054356d commit 0b5f3aa
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2034,16 +2034,42 @@ an optional <var>reason</var>:
<li><p>Set <var>signal</var>'s [=AbortSignal/abort reason=] to <var>reason</var> if it is given;
otherwise to a new "{{AbortError!!exception}}" {{DOMException}}.

<li><p>Let <var>dependentSignalsToAbort</var> be a new <a for=/>list</a>.

<li>
<p><a for=set>For each</a> <var>dependentSignal</var> of <var>signal</var>'s
[=AbortSignal/dependent signals=]:

<ol>
<li>
<p>If <var>dependentSignal</var> is not [=AbortSignal/aborted=], then:

<ol>
<li><p>Set <var>dependentSignal</var>'s [=AbortSignal/abort reason=] to <var>signal</var>'s
[=AbortSignal/abort reason=].

<li><p><a for=list>Append</a> <var>dependentSignal</var> to
<var>dependentSignalsToAbort</var>.
</ol>
</ol>

<li><p><a>Run the abort steps</a> for <var>signal</var>.

<li><p><a for=set>For each</a> <var>dependentSignal</var> of <var>dependentSignalsToAbort</var>,
<a>run the abort steps</a> for <var>dependentSignal</var>.
</ol>
</div>

<div algorithm>
<p>To <dfn>run the abort steps</dfn> for an {{AbortSignal}} <var>signal</var>:

<ol>
<li><p><a for=set>For each</a> <var>algorithm</var> of <var>signal</var>'s
[=AbortSignal/abort algorithms=]: run <var>algorithm</var>.

<li><p><a for=set>Empty</a> <var>signal</var>'s <a for=AbortSignal>abort algorithms</a>.

<li><p>[=Fire an event=] named {{AbortSignal/abort}} at <var>signal</var>.

<li><p><a for=set>For each</a> <var>dependentSignal</var> of <var>signal</var>'s
[=AbortSignal/dependent signals=], [=AbortSignal/signal abort=] on <var>dependentSignal</var> with
<var>signal</var>'s [=AbortSignal/abort reason=].
</ol>
</div>

Expand Down

0 comments on commit 0b5f3aa

Please sign in to comment.