Skip to content

Commit ee85da2

Browse files
annevkdomenic
andauthored
Editorial: minor cleanup in fetch() around aborting
Also leave internal notes on the unfortunate duplication of logic. Closes #1187. Co-authored-by: Domenic Denicola <[email protected]>
1 parent 6128ca3 commit ee85da2

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

fetch.bs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7882,21 +7882,31 @@ method steps are:
78827882
<ol>
78837883
<li><p>Set <var>locallyAborted</var> to true.
78847884

7885-
<li><p><a>Abort the <code>fetch()</code> call</a> with <var>p</var>, <var>request</var>, <var>responseObject</var>,
7886-
and <var>requestObject</var>'s <a for=Request>signal</a>'s <a for=AbortSignal>abort reason</a>.
7885+
<li><p><a for=/>Assert</a>: <var>controller</var> is non-null.
78877886

7888-
<li><p>If <var>controller</var> is not null, then <a for="fetch controller">abort</a>
7889-
<var>controller</var> with <var>requestObject</var>'s <a for=Request>signal</a>'s
7887+
<li><p><a for="fetch controller">Abort</a> <var>controller</var> with <var>requestObject</var>'s
7888+
<a for=Request>signal</a>'s <a for=AbortSignal>abort reason</a>.
7889+
7890+
<li><p><a>Abort the <code>fetch()</code> call</a> with <var>p</var>, <var>request</var>,
7891+
<var>responseObject</var>, and <var>requestObject</var>'s <a for=Request>signal</a>'s
78907892
<a for=AbortSignal>abort reason</a>.
7893+
<!-- ABORT-DUPLICATION
7894+
This step would ideally be skipped for HTTP(S) requests, except that currently the HTTP
7895+
cache integration with streams is not as good as it can be. Unfortunately we definitely need
7896+
to do this for about:blank and blob: & data: URLs.
7897+
7898+
The conceptual problem is that the underlying operation might not have been aborted by the
7899+
time JavaScript gets a signal. See also:
7900+
https://github.com/whatwg/dom/issues/1031#issuecomment-1233206400 -->
78917901
</ol>
78927902

78937903
<li>
78947904
<p><p>Set <var>controller</var> to the result of calling <a for=/>fetch</a> given
78957905
<var>request</var> and <a for=fetch><i>processResponse</i></a> given <var>response</var> being
7896-
these substeps:
7906+
these steps:
78977907

78987908
<ol>
7899-
<li><p>If <var>locallyAborted</var> is true, terminate these substeps.
7909+
<li><p>If <var>locallyAborted</var> is true, then abort these steps.
79007910

79017911
<li>
79027912
<p>If <var>response</var>'s <a for=response>aborted flag</a> is set, then:
@@ -7908,10 +7918,12 @@ method steps are:
79087918

79097919
<li><p><a>Abort the <code>fetch()</code> call</a> with <var>p</var>, <var>request</var>,
79107920
<var>responseObject</var>, and <var>deserializedError</var>.
7921+
7922+
<li><p>Abort these steps.
79117923
</ol>
79127924

79137925
<li><p>If <var>response</var> is a <a>network error</a>, then <a for=/>reject</a> <var>p</var>
7914-
with a {{TypeError}} and terminate these substeps.
7926+
with a {{TypeError}} and abort these steps.
79157927

79167928
<li><p>Set <var>responseObject</var> to the result of <a for=Response>creating</a> a {{Response}}
79177929
object, given <var>response</var>, "<code>immutable</code>", and <var>relevantRealm</var>.
@@ -7922,24 +7934,28 @@ method steps are:
79227934
<li><p>Return <var>p</var>.
79237935
</ol>
79247936

7925-
<p>To <dfn lt="Abort the fetch() call" export id=abort-fetch>abort a <code>fetch()</code> call</dfn> with a
7926-
<var>promise</var>, <var>request</var>, <var>responseObject</var>, and an <var>error</var>, run these steps:
7937+
<p>To <dfn lt="Abort the fetch() call" export id=abort-fetch>abort a <code>fetch()</code> call</dfn>
7938+
with a <var>promise</var>, <var>request</var>, <var>responseObject</var>, and an <var>error</var>:
79277939

79287940
<ol>
79297941
<li>
79307942
<p><a for=/>Reject</a> <var>promise</var> with <var>error</var>.
79317943

79327944
<p class=note>This is a no-op if <var>promise</var> has already fulfilled.
79337945

7934-
<li><p>If <var>request</var>'s <a for=request>body</a> is not null and is
7946+
<li><p>If <var>request</var>'s <a for=request>body</a> is non-null and is
79357947
<a for=ReadableStream>readable</a>, then <a for=ReadableStream>cancel</a> <var>request</var>'s
79367948
<a for=request>body</a> with <var>error</var>.
79377949

79387950
<li><p>If <var>responseObject</var> is null, then return.
7951+
<!-- ABORT-DUPLICATION
7952+
We might not need this and subsequent steps if we had better stream integration with the HTTP
7953+
cache. However, about:blank and blob: & data: URLs would probably still need this as they do
7954+
not have any cancelation logic. -->
79397955

79407956
<li><p>Let <var>response</var> be <var>responseObject</var>'s <a for=Response>response</a>.
79417957

7942-
<li><p>If <var>response</var>'s <a for=response>body</a> is not null and is
7958+
<li><p>If <var>response</var>'s <a for=response>body</a> is non-null and is
79437959
<a for=ReadableStream>readable</a>, then <a for=ReadableStream>error</a> <var>response</var>'s
79447960
<a for=response>body</a> with <var>error</var>.
79457961
</ol>

0 commit comments

Comments
 (0)