Skip to content

Commit

Permalink
Only finalize after finale
Browse files Browse the repository at this point in the history
  • Loading branch information
noamr committed Oct 10, 2021
1 parent 8d691c0 commit d8322b0
Showing 1 changed file with 33 additions and 23 deletions.
56 changes: 33 additions & 23 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,9 @@ this is also tracked internally using the request's <a for=request>timing allow
<dfn export for=response>service worker timing info</dfn> (null or a
<a for=/>service worker timing info</a>), which is initially null.

<p>A <a for=/>response</a> has an associated
<dfn for=response>finalize</dfn> (null or an algorithm with no parameters), which is initially null.

<hr>

<p>A <a for=/>response</a> whose
Expand Down Expand Up @@ -4124,6 +4127,22 @@ steps:
<a for=/>response</a> <var>response</var>, run these steps:

<ol>
<li>
<p>Let <var>finalizeResponse</var> be the following steps:</p>
<ol>
<li><p>If <var>fetchParams</var>'s <a for="fetch params">request</a>'s
<a for=request>done flag</a> is set, then return.

<li><p>Set <var>fetchParams</var>'s <a for="fetch params">request</a>'s
<a for=request>done flag</a>.

<li><p>If <var>fetchParams</var>'s <a for="fetch params">process response done</a> is not null,
then <a>queue a fetch task</a> to run <var>fetchParams</var>'s
<a for="fetch params">process response done</a> given <var>response</var>,
with <var>fetchParams</var>'s <a for="fetch params">task destination</a>.
</ol>
</li>

<li>
<p>If <var>response</var> is a <a>network error</a>, then:

Expand All @@ -4140,6 +4159,9 @@ steps:
<a>creating an opaque timing info</a> for <var>fetchParams</var>'s
<a for="fetch params">timing info</a>.
</ol>

<p>Otherwise, set <var>response</var>'s <a for="response">finalize</a> to
<var>finalizeResponse</var>.</p>
</li>

<li><p>If <var>fetchParams</var>'s <a for="fetch params">process response</a> is non-null, then
Expand Down Expand Up @@ -4168,24 +4190,10 @@ steps:
<a for="fetch params">task destination</a>.
</ol>

<li><p>If <var>response</var> is a <a>network error</a>, then <a>finalize response</a> for
<var>fetchParams</var> and <var>response</var>.
</ol>

<p>To <dfn>finalize response</dfn> given a <a for=/>fetch params</a> <var>fetchParams</var> and a
<a for=/>response</a> <var>response</var>, run these steps:

<ol>
<li><p>If <var>fetchParams</var>'s <a for="fetch params">request</a>'s <a for=request>done flag</a>
is set, then return.

<li><p>Set <var>fetchParams</var>'s <a for="fetch params">request</a>'s
<a for=request>done flag</a>.

<li><p>If <var>fetchParams</var>'s <a for="fetch params">process response done</a> is not null,
then <a>queue a fetch task</a> to run <var>fetchParams</var>'s
<a for="fetch params">process response done</a> given <var>response</var>,
with <var>fetchParams</var>'s <a for="fetch params">task destination</a>.
<li>
<p>If <var>response</var> is a <a>network error</a>, then call
<var>finalizeResponse</var>.
</li>
</ol>

<p>To <dfn export>finalize and report timing</dfn> given a <a for=/>response</a>
Expand Down Expand Up @@ -5531,18 +5539,20 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
agent to <a for=fetch>suspend</a> the ongoing fetch.
</ol>

<li><p>Otherwise, if the bytes transmission for <var>response</var>'s message body is done
normally and <var>stream</var> is <a for=ReadableStream>readable</a>, then
<a for=ReadableStream>close</a> <var>stream</var>, <a for=/>finalize response</a> for
<var>fetchParams</var> and <var>response</var>, and abort these in-parallel steps.
<li><p>Otherwise, if <var>response</var>'s <a for=response>finalize</a> is not null, the
bytes transmission for <var>response</var>'s message body is done normally and
<var>stream</var> is <a for=ReadableStream>readable</a>, then <a for=ReadableStream>close</a>
<var>stream</var>, call <var>response</var>'s <a for=response>finalize</a>, and abort these
in-parallel steps.
</ol>
</ol>

<li>
<p><a>If aborted</a>, then:

<ol>
<li><a for=/>Finalize response</a> for <var>fetchParams</var> and <var>response</var>.
<li>If <var>response</var>'s <a for=response>finalize</a> is not null, <var>response</var>'s\
<a for=response>finalize</a>.

<li><p>Let <var>aborted</var> be the termination's aborted flag.

Expand Down

0 comments on commit d8322b0

Please sign in to comment.