Re: [whatwg/fetch] Deferred fetching (PR #1647)

@annevk commented on this pull request.

Before addressing these comments, maybe squash and merge the existing commits and rebase on main. 103 is a bit much. :-)

> + <li><p><a>Populate request from client</a> given <var>request</var>.
+
+ <li><p>Set <var>request</var>'s <a for=request>service-workers mode</a> to "<code>none</code>".
+
+ <li><p>Set <var>request</var>'s <a for=request>keepalive</a> to true.
+
+ <li><p>Let <var>deferredRecord</var> be a new <a>deferred fetch record</a> whose
+ <a for="deferred fetch record">request</a> is <var>request</var>, and whose
+ <a for="deferred fetch record">notify invoked</a> is
+ <var>onActivatedWithoutTermination</var>.
+
+ <li><p><a for=list>Append</a> <var>deferredRecord</var> to <var>request</var>'s
+ <a for=request>client</a>'s <a>fetch group</a>'s <a for="fetch group">deferred fetch records</a>.
+
+ <li>
+  <p>If <var>activateAfter</var> is non-null, then run the following steps <a>in parallel</a>:</p>

```suggestion
  <p>If <var>activateAfter</var> is non-null, then run the following steps <a>in parallel</a>:
```

> +
+ <li><p>If <var>requestObject</var>'s <a for=Request>signal</a> is <a for=AbortSignal>aborted</a>,
+ then throw <a for=Request>signal</a>'s <a for=AbortSignal>abort reason</a>.
+
+ <li><p>Let <var>request</var> be <var>requestObject</var>'s <a for=Request>request</a>.
+
+ <li><p>Let <var>activateAfter</var> be null.
+
+ <li><p>If <var>init</var> is given and <var>init</var>["{{DeferredRequestInit/activateAfter}}"]
+ <a for=map>exists</a>, then set <var>activateAfter</var> to
+ <var>init</var>["{{DeferredRequestInit/activateAfter}}"].
+
+ <li><p>If <var>activateAfter</var> is less than 0, then throw a {{RangeError}}.
+
+ <li><p>If <var>request</var>'s <a for=request>client</a> is not a <a>fully active</a>
+ {{Document}}, then throw a {{TypeError}}.

A client is never a document.

> +
+ <li><p>Set <var>deferredRecord</var>'s <a for="deferred fetch record">invoke state</a> to
+ "<code>sent</code>".
+
+ <li><p><a for=/>Fetch</a> <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>.
+
+ <li><p><a>Queue a global task</a> on the <a>deferred fetch task source</a> with
+ <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s
+ <a for=request>client</a>'s <a for="environment settings object">global object</a> to run
+ <var>deferredRecord</var>'s <a for="deferred fetch record">notify invoked</a>.
+</ol>
+</div>
+
+<h4 id=deferred-fetch-quota>Deferred fetching quota</h4>
+
+<!-- non-normative -->

```suggestion
<p><em>This section is non-normative.</em>

```

> + "<code>sent</code>".
+
+ <li><p><a for=/>Fetch</a> <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>.
+
+ <li><p><a>Queue a global task</a> on the <a>deferred fetch task source</a> with
+ <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s
+ <a for=request>client</a>'s <a for="environment settings object">global object</a> to run
+ <var>deferredRecord</var>'s <a for="deferred fetch record">notify invoked</a>.
+</ol>
+</div>
+
+<h4 id=deferred-fetch-quota>Deferred fetching quota</h4>
+
+<!-- non-normative -->
+<p>The deferred-fetch quota is allocated to a <a for=/>top-level traversable</a> (a "tab"),
+amounting to 640 kibibytes. The top-level {{Document}} and its same-origin directly nested documents

```suggestion
amounting to 640 kibibytes. The top-level document and its same-origin directly nested documents
```
Please either use "document" (possibly as `<a for=/>document</a>`) or `{{Document}} object`. This applies quite a few times.

> +<pre><code>
++ https://me.example.com with Permissions-policy: deferred-fetch=(self "https://ok.example.com")
+| (See below for quota)
+|
++ ---- + https://me.example.com
+|      | Shares quota with the <a for=/>top-level traversable</a>, as they're same origin.
+|      |
+|      + ---- + https://x.example.com
+|               8 kibibytes.
+|
+|
++ ---- + https://x.example.com
+|        8 kibibytes.
+|        |
+|        + https://me.example.com
+|          0. Even though it's same origin with the <a for=/>top-level traversable</a>, it does not
+|          automatically share its quota as they are separated by a cross-origin intermediary.
+|
++ ---- + https://ok.example.com/good
+|      | 64 kibibytes, granted via the "{{PermissionsPolicy/deferred-fetch}}" policy.
+|      |
+|      + ---- + https://x.example.com
+|               0. Only documents with the same origin as the <a for=/>top-level traversable</a> can
+|               grant the 8 kibibytes based on the "{{PermissionsPolicy/deferred-fetch-minimal}}" policy.
+|
++ ---- + https://ok.example.com/redirect, navigated to https://x.example.com
+|        0. The reserved 64 kibibytes for https://ok.example.com are not available for https://x.example.com.
+|
++ ---- + https://ok.example.com/back, navigated to https://me.example.com
+         Shares quota with the <a for=/>top-level traversable</a>, as they're same origin.
+</code></pre>

I don't think this is accessible so I don't think we can include this as-is.

> +descendants share a quota of 384 kibibytes. That value is computed as such:
+<ul>
+ <li><p>640 kibibytes are initially granted to the <a for=/>top-level traversable</a>.
+
+ <li><p>128 kibibytes are reserved for the "{{PermissionsPolicy/deferred-fetch-minimal}}" policy.
+
+ <li><p>64 kibibytes are reserved for the container navigating to
+ <code>https://ok.example/good</code>.
+
+ <li><p>64 kibibytes are reserved for the container navigating to
+ <code>https://ok.example/redirect</code>, and lost when it navigates away.
+
+ <li><code>https://ok.example.com/back</code> did not reserve 64 kibibytes, because it navigated
+ back to <a for=/>top-level traversable</a>'s origin.
+
+ <li><p>640 - 128 - 64 - 64 = 384 kibibytes.

Please use `&minus;` for subtraction.

> +
+<div algorithm>
+<p>To <dfn export>potentially free deferred-fetch quota</dfn> for a {{Document}}
+<var>document</var>, if <var>document</var>'s <a>node navigable</a>'s <a>container document</a> is
+not null, and its <a for=Document>origin</a> is <a>same origin</a> with <var>document</var>, then
+set <var>document</var>'s <a>node navigable</a>'s <a>navigable container</a>'s
+<a>reserved deferred-fetch quota</a> to 0.
+
+<p class=note>This is called when a {{Document}} is created. It ensures that same-origin nested
+documents don't reserve quota, as they anyway share their parent quota. It can only be called upon
+document creation, as the <a for=Document>origin</a> of the {{Document}} is only known after
+redirects are handled.
+</div>
+
+<div algorithm>
+<p>To get the <dfn>deferred-fetch control document</dfn> of a {{Document}} <var>document</var>:

Here it should be `{{Document}} object` for instance.

> @@ -8576,6 +9047,135 @@ with a <var>promise</var>, <var>request</var>, <var>responseObject</var>, and an
 </ol>
 </div>
 
+<p>A {{FetchLaterResult}} has an associated <dfn for=FetchLaterResult>activated getter steps</dfn>,
+which is an algorithm returning a boolean.
+
+<div algorithm>
+<p>The <dfn attribute for=FetchLaterResult><code>activated</code></dfn> getter steps are to call

```suggestion
<p>The <dfn attribute for=FetchLaterResult><code>activated</code></dfn> getter steps are to return the result of running
```
and wrapping

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/pull/1647#pullrequestreview-2752628128
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/fetch/pull/1647/review/2752628128@github.com>

Received on Wednesday, 9 April 2025 09:04:30 UTC