Skip to content

Commit 744d8b3

Browse files
committed
Introduce fetch registries so when a document/worker dies, fetches get terminated. (Except those fetches that need to outlive the document/worker.)
This fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=23878
1 parent 1d8173a commit 744d8b3

File tree

2 files changed

+146
-21
lines changed

2 files changed

+146
-21
lines changed

Overview.html

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ <h2 class="no-num no-toc" id="table-of-contents">Table of Contents</h2>
5050
<li><a href="#bodies"><span class="secno">2.1.3 </span>Bodies</a></li>
5151
<li><a href="#requests"><span class="secno">2.1.4 </span>Requests</a></li>
5252
<li><a href="#responses"><span class="secno">2.1.5 </span>Responses</a></ul></li>
53-
<li><a href="#authentication-entries"><span class="secno">2.2 </span>Authentication entries</a></ul></li>
53+
<li><a href="#authentication-entries"><span class="secno">2.2 </span>Authentication entries</a></li>
54+
<li><a href="#fetch-registries"><span class="secno">2.3 </span>Fetch registries</a></ul></li>
5455
<li><a href="#http-extensions"><span class="secno">3 </span>HTTP extensions</a>
5556
<ul class="toc">
5657
<li><a href="#origin-header"><span class="secno">3.1 </span>`<code title="">Origin</code>` header</a></li>
@@ -184,6 +185,16 @@ <h2 id="infrastructure"><span class="secno">2 </span>Infrastructure</h2>
184185
<a class="external" href="https://html.spec.whatwg.org/multipage/webappapis.html#networking-task-source">networking task source</a>.
185186
</ol>
186187

188+
<p>To <dfn id="queue-a-fetch-done-task">queue a fetch done task</dfn> given a <var title="">request</var> and
189+
<var title="">response</var>, run these steps:
190+
191+
<ol>
192+
<li><p>Set <var title="">request</var>'s <a href="#done-flag">done flag</a>.
193+
194+
<li><p><a href="#queue-a-fetch-task">Queue a fetch task</a> on <var title="">request</var> to
195+
<dfn id="process-response-end-of-file">process response end-of-file</dfn> for <var title="">response</var>.
196+
</ol>
197+
187198

188199
<h3 id="http"><span class="secno">2.1 </span>HTTP</h3>
189200

@@ -468,6 +479,13 @@ <h4 id="requests"><span class="secno">2.1.4 </span>Requests</h4>
468479
null when <a class="external" href="https://html.spec.whatwg.org/multipage/browsers.html#navigate" title="navigate">navigating</a>, service worker
469480
script updates, etc.</span>
470481

482+
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
483+
<dfn id="keep-alive-flag">keep-alive flag</dfn>. Unless stated otherwise it is unset.
484+
485+
<p class="note no-backref">This is used by <code>navigator.sendBeacon</code> and the HTML
486+
<code>img</code> element to outlive the
487+
<a class="external" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a>.
488+
471489
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated
472490
<dfn id="skip-service-worker-flag">skip service worker flag</dfn>. Unless stated otherwise it is unset.
473491

@@ -827,12 +845,16 @@ <h4 id="requests"><span class="secno">2.1.4 </span>Requests</h4>
827845
"<code title="">basic</code>", "<code title="">cors</code>", and "<code title="">opaque</code>".
828846
Unless stated otherwise, it is "<code title="">basic</code>".
829847

848+
<p>A <a href="#concept-request" title="concept-request">request</a> has an associated <dfn id="done-flag">done flag</dfn>.
849+
Unless stated otherwise, it is unset.
850+
830851
<p class="note no-backref">A <a href="#concept-request" title="concept-request">request</a>'s
831852
<a href="#concept-request-url-list" title="concept-request-url-list">url list</a>,
832853
<a href="#concept-request-current-url" title="concept-request-current-url">current url</a>,
833-
<a href="#concept-request-redirect-count" title="concept-request-redirect-count">redirect count</a>, and
834-
<a href="#concept-request-response-tainting" title="concept-request-response-tainting">response tainting</a> are used as
835-
bookkeeping details by the <a href="#concept-fetch" title="concept-fetch">fetch</a> algorithm.
854+
<a href="#concept-request-redirect-count" title="concept-request-redirect-count">redirect count</a>,
855+
<a href="#concept-request-response-tainting" title="concept-request-response-tainting">response tainting</a>, and
856+
<a href="#done-flag">done flag</a> are used as bookkeeping details by the
857+
<a href="#concept-fetch" title="concept-fetch">fetch</a> algorithm.
836858

837859
<hr>
838860

@@ -1038,6 +1060,34 @@ <h3 id="authentication-entries"><span class="secno">2.2 </span>Authentication en
10381060
<a href="#refsHTTPAUTH">[HTTPAUTH]</a>
10391061

10401062

1063+
<h3 id="fetch-registries"><span class="secno">2.3 </span>Fetch registries</h3>
1064+
1065+
<p>Each <a class="external" href="https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object">environment settings object</a> has an associated
1066+
<dfn id="concept-fetch-registry" title="concept-fetch-registry">fetch registry</dfn>.
1067+
1068+
<p>A <a href="#concept-fetch-registry" title="concept-fetch-registry">fetch registry</a> holds an ordered list of
1069+
<dfn id="concept-fetch-record" title="concept-fetch-record">fetch records</dfn>.
1070+
1071+
<p>A <a href="#concept-fetch-record" title="concept-fetch-record">fetch record</a> has an associated
1072+
<dfn id="concept-fetch-record-request" title="concept-fetch-record-request">request</dfn> (a
1073+
<a href="#concept-request" title="concept-request">request</a>).
1074+
1075+
<p>A <a href="#concept-fetch-record" title="concept-fetch-record">fetch record</a> has an associated
1076+
<dfn id="concept-fetch-record-fetch" title="concept-fetch-record-fetch">fetch</dfn> (a
1077+
<a href="#concept-fetch" title="concept-fetch">fetch</a> algorithm or null).
1078+
1079+
<hr>
1080+
1081+
<p>When a <a href="#concept-fetch-registry" title="concept-fetch-registry">fetch registry</a> is
1082+
<dfn id="concept-fetch-registry-terminate" title="concept-fetch-registry-terminate">terminated</dfn>, for each associated
1083+
<a href="#concept-fetch-record" title="concept-fetch-record">fetch record</a> whose
1084+
<span title="concept-request-record-request">request</span>'s <a href="#done-flag">done flag</a> or
1085+
<a href="#keep-alive-flag">keep-alive flag</a> is unset,
1086+
<a href="#concept-fetch-terminate" title="concept-fetch-terminate">terminate</a> the
1087+
<a href="#concept-fetch-record" title="concept-fetch-record">fetch record</a>'s
1088+
<a href="#concept-fetch-record-fetch" title="concept-fetch-record-fetch">fetch</a> with reason <i title="">fatal</i>.
1089+
1090+
10411091

10421092
<h2 id="http-extensions"><span class="secno">3 </span>HTTP extensions</h2>
10431093

@@ -1357,6 +1407,22 @@ <h2 id="fetching"><span class="secno">4 </span>Fetching</h2>
13571407
for HTTP/2, and equivalent information used to prioritize dispatch and processing of
13581408
HTTP/1 fetches.
13591409

1410+
<li>
1411+
<p>If <var title="">request</var>'s <a href="#concept-request-client" title="concept-request-client">client</a> is
1412+
non-null, run these substeps:
1413+
1414+
<ol>
1415+
<li><p>Let <var title="">record</var> be a new
1416+
<a href="#concept-fetch-record" title="concept-fetch-record">fetch record</a> consisting of
1417+
<var title="">request</var> and this instance of the
1418+
<a href="#concept-fetch" title="concept-fetch">fetch</a> algorithm.
1419+
1420+
<li><p>Append <var title="">record</var> to <var title="">request</var>'s
1421+
<a href="#concept-request-client" title="concept-request-client">client</a>'s
1422+
<a href="#concept-fetch-registry" title="concept-fetch-registry">fetch registry</a> list of
1423+
<a href="#concept-fetch-record" title="concept-fetch-record">fetch records</a>.
1424+
</ol>
1425+
13601426
<li><p>Return the result of performing a <a href="#concept-main-fetch" title="concept-main-fetch">main fetch</a>
13611427
using <var title="">request</var>.
13621428
</ol>
@@ -1565,8 +1631,8 @@ <h3 id="main-fetch"><span class="secno">4.1 </span>Main fetch</h3>
15651631
<li><a href="#queue-a-fetch-task">Queue a fetch task</a> on <var title="">request</var> to
15661632
<dfn id="process-response-body">process response body</dfn> for <var title="">response</var>.
15671633

1568-
<li><p><a href="#queue-a-fetch-task">Queue a fetch task</a> on <var title="">request</var> to
1569-
<dfn id="process-response-end-of-file">process response end-of-file</dfn> for <var title="">response</var>.
1634+
<li><p><a href="#queue-a-fetch-done-task">Queue a fetch done task</a> using <var title="">request</var> and
1635+
<var title="">response</var>.
15701636
</ol>
15711637

15721638
<li>
@@ -1586,15 +1652,12 @@ <h3 id="main-fetch"><span class="secno">4.1 </span>Main fetch</h3>
15861652
<p>Once end-of-file has been pushed to <var title="">response</var>'s
15871653
<a href="#concept-response-body" title="concept-response-body">body</a> or <var title="">response</var> has a
15881654
<a href="#concept-response-termination-reason" title="concept-response-termination-reason">termination reason</a>,
1589-
<a href="#queue-a-fetch-task">queue a fetch task</a> on <var title="">request</var> to
1590-
<a href="#process-response-end-of-file">process response end-of-file</a> for <var title="">response</var>.
1655+
<a href="#queue-a-fetch-done-task">queue a fetch done task</a> using <var title="">request</var> and
1656+
<var title="">response</var>.
15911657

15921658
<p class="note">Ideally FTP/HTTP define this in more detail and this becomes a set of
15931659
simple hooks.
15941660
</ol>
1595-
1596-
<p>Use the <a class="external" href="https://html.spec.whatwg.org/multipage/webappapis.html#networking-task-source">networking task source</a> for these
1597-
<a class="external" href="https://html.spec.whatwg.org/multipage/webappapis.html#concept-task" title="concept-task">tasks</a>.
15981661
</ol>
15991662

16001663

Overview.src.html

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ <h2>Infrastructure</h2>
133133
<span data-anolis-spec=html>networking task source</span>.
134134
</ol>
135135

136+
<p>To <dfn>queue a fetch done task</dfn> given a <var title>request</var> and
137+
<var title>response</var>, run these steps:
138+
139+
<ol>
140+
<li><p>Set <var title>request</var>'s <span>done flag</span>.
141+
142+
<li><p><span>Queue a fetch task</span> on <var title>request</var> to
143+
<dfn>process response end-of-file</dfn> for <var title>response</var>.
144+
</ol>
145+
136146

137147
<h3>HTTP</h3>
138148

@@ -417,6 +427,13 @@ <h4>Requests</h4>
417427
null when <span data-anolis-spec=html title=navigate>navigating</span>, service worker
418428
script updates, etc.</span>
419429

430+
<p>A <span title=concept-request>request</span> has an associated
431+
<dfn>keep-alive flag</dfn>. Unless stated otherwise it is unset.
432+
433+
<p class="note no-backref">This is used by <code>navigator.sendBeacon</code> and the HTML
434+
<code>img</code> element to outlive the
435+
<span data-anolis-spec=html>environment settings object</span>.
436+
420437
<p>A <span title=concept-request>request</span> has an associated
421438
<dfn>skip service worker flag</dfn>. Unless stated otherwise it is unset.
422439

@@ -776,12 +793,16 @@ <h4>Requests</h4>
776793
"<code title>basic</code>", "<code title>cors</code>", and "<code title>opaque</code>".
777794
Unless stated otherwise, it is "<code title>basic</code>".
778795

796+
<p>A <span title=concept-request>request</span> has an associated <dfn>done flag</dfn>.
797+
Unless stated otherwise, it is unset.
798+
779799
<p class="note no-backref">A <span title=concept-request>request</span>'s
780800
<span title=concept-request-url-list>url list</span>,
781801
<span title=concept-request-current-url>current url</span>,
782-
<span title=concept-request-redirect-count>redirect count</span>, and
783-
<span title=concept-request-response-tainting>response tainting</span> are used as
784-
bookkeeping details by the <span title=concept-fetch>fetch</span> algorithm.
802+
<span title=concept-request-redirect-count>redirect count</span>,
803+
<span title=concept-request-response-tainting>response tainting</span>, and
804+
<span>done flag</span> are used as bookkeeping details by the
805+
<span title=concept-fetch>fetch</span> algorithm.
785806

786807
<hr>
787808

@@ -987,6 +1008,34 @@ <h3>Authentication entries</h3>
9871008
<span data-anolis-ref>HTTPAUTH</span>
9881009

9891010

1011+
<h3>Fetch registries</h3>
1012+
1013+
<p>Each <span data-anolis-spec=html>environment settings object</span> has an associated
1014+
<dfn title=concept-fetch-registry>fetch registry</dfn>.
1015+
1016+
<p>A <span title=concept-fetch-registry>fetch registry</span> holds an ordered list of
1017+
<dfn title=concept-fetch-record>fetch records</dfn>.
1018+
1019+
<p>A <span title=concept-fetch-record>fetch record</span> has an associated
1020+
<dfn title=concept-fetch-record-request>request</dfn> (a
1021+
<span title=concept-request>request</span>).
1022+
1023+
<p>A <span title=concept-fetch-record>fetch record</span> has an associated
1024+
<dfn title=concept-fetch-record-fetch>fetch</dfn> (a
1025+
<span title=concept-fetch>fetch</span> algorithm or null).
1026+
1027+
<hr>
1028+
1029+
<p>When a <span title=concept-fetch-registry>fetch registry</span> is
1030+
<dfn title=concept-fetch-registry-terminate>terminated</dfn>, for each associated
1031+
<span title=concept-fetch-record>fetch record</span> whose
1032+
<span title=concept-request-record-request>request</span>'s <span>done flag</span> or
1033+
<span>keep-alive flag</span> is unset,
1034+
<span title=concept-fetch-terminate>terminate</span> the
1035+
<span title=concept-fetch-record>fetch record</span>'s
1036+
<span title=concept-fetch-record-fetch>fetch</span> with reason <i title>fatal</i>.
1037+
1038+
9901039

9911040
<h2>HTTP extensions</h2>
9921041

@@ -1306,6 +1355,22 @@ <h2>Fetching</h2>
13061355
for HTTP/2, and equivalent information used to prioritize dispatch and processing of
13071356
HTTP/1 fetches.
13081357

1358+
<li>
1359+
<p>If <var title>request</var>'s <span title=concept-request-client>client</span> is
1360+
non-null, run these substeps:
1361+
1362+
<ol>
1363+
<li><p>Let <var title>record</var> be a new
1364+
<span title=concept-fetch-record>fetch record</span> consisting of
1365+
<var title>request</var> and this instance of the
1366+
<span title=concept-fetch>fetch</span> algorithm.
1367+
1368+
<li><p>Append <var title>record</var> to <var title>request</var>'s
1369+
<span title=concept-request-client>client</span>'s
1370+
<span title=concept-fetch-registry>fetch registry</span> list of
1371+
<span title=concept-fetch-record>fetch records</span>.
1372+
</ol>
1373+
13091374
<li><p>Return the result of performing a <span title=concept-main-fetch>main fetch</span>
13101375
using <var title>request</var>.
13111376
</ol>
@@ -1514,8 +1579,8 @@ <h3>Main fetch</h3>
15141579
<li><span>Queue a fetch task</span> on <var title>request</var> to
15151580
<dfn>process response body</dfn> for <var title>response</var>.
15161581

1517-
<li><p><span>Queue a fetch task</span> on <var title>request</var> to
1518-
<dfn>process response end-of-file</dfn> for <var title>response</var>.
1582+
<li><p><span>Queue a fetch done task</span> using <var title>request</var> and
1583+
<var title>response</var>.
15191584
</ol>
15201585

15211586
<li>
@@ -1535,15 +1600,12 @@ <h3>Main fetch</h3>
15351600
<p>Once end-of-file has been pushed to <var title>response</var>'s
15361601
<span title=concept-response-body>body</span> or <var title>response</var> has a
15371602
<span title=concept-response-termination-reason>termination reason</span>,
1538-
<span>queue a fetch task</span> on <var title>request</var> to
1539-
<span>process response end-of-file</span> for <var title>response</var>.
1603+
<span>queue a fetch done task</span> using <var title>request</var> and
1604+
<var title>response</var>.
15401605

15411606
<p class=note>Ideally FTP/HTTP define this in more detail and this becomes a set of
15421607
simple hooks.
15431608
</ol>
1544-
1545-
<p>Use the <span data-anolis-spec=html>networking task source</span> for these
1546-
<span data-anolis-spec=html title=concept-task>tasks</span>.
15471609
</ol>
15481610

15491611

0 commit comments

Comments
 (0)