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

@mingyc commented on this pull request.

PTAL, added some more comments.

> @@ -6615,6 +6706,62 @@ agent's <a>CORS-preflight cache</a> for which there is a <a>cache entry match</a
 </ol>
 </div>
 
+<h3 id=deferred-fetching>Deferred fetching</h3>
+
+<p>Deferred fetches allow callers to request that a fetch is invoked at the latest possible moment,

> at the latest possible moment

Looking at this again, it seems that one of the situations, i.e. `after a timeout after it is deactivated`, is not really "the latest possible moment". Should we rephrase this? 

> +   <a for=request>body</a>'s <a for=body>length</a>.
+  </ol>
+ </li>
+
+ <li><p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> in
+ <var>request</var>'s <a for=request>client</a>'s <a for=fetch>fetch group</a>'s
+ <a for="fetch group">deferred fetch records</a>: if <var>deferredRecord</var>'s
+ <a for="deferred fetch record">request</a>'s <a for=request>body</a> is not null and
+ <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s <a for=request>URL</a>'s
+ <a for=url>origin</a> is <a>same origin</a> with <var>request</var>'s <a for=request>URL</a>'s
+ <a for=url>origin</a>, then increment <var>totalScheduledDeferredBytesForOrigin</var> by
+ <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s <a for=request>body</a>'s
+ <a for=body>length</a>.
+
+ <li><p>If <var>totalScheduledDeferredBytesForOrigin</var> is greater than 64 kilobytes, then
+ throw a {{QuotaExceededError}}.

If the discussion at https://github.com/whatwg/fetch/pull/1647#discussion_r1197485829 is resolved and the API shape is changed to return a `DeferredFetchResult` instead of `Promise`, should we consider to return null here in addition to throw an error?

> @@ -8449,6 +8597,60 @@ with a <var>promise</var>, <var>request</var>, <var>responseObject</var>, and an
 </div>
 
 
+<h3 id=fetch-later-method>FetchLater method</h3>
+
+<pre class=idl>
+
+dictionary DeferredRequestInit : RequestInit {
+  DOMHighResTimeStamp backgroundTimeout;

In addition to which type of event to support for this timeout, in our previous PendingBeacon proposal we have also specifies that the user agent has freedom to bundle pending beacon request together, `the beacon is not guaranteed to be sent at exactly this many milliseconds after hidden, because the browser has freedom to bundle/batch multiple beacons, and the browser might send out earlier than specified value.` ([source here](https://github.com/WICG/pending-beacon/blob/0af026cf18312cc612878ada3ad40350f497a006/README.md#properties)). This was for saving resources, and there might be different max time limit for how long a bfcached document can stay in different browser, e.g. Chrome is 10 minutes, while FF is 30 minutes.

Do you think the above can still be added to `fetchLater()`?

>  
+<ol>
+ <li>
+  <p><a for=list>For each</a> <a for="fetch group">deferred fetch record</a>
+  <var>deferredRecord</var> in <var>fetchGroup</var>'s
+  <a for="fetch group">deferred fetch records</a> whose <a for="deferred fetch record">invoked</a> is
+  false:
+
+  <ol>
+   <li><p>If <var>deferredRecord</var>'s <a for="deferred fetch record">pending steps</a> is not
+   null then <a>abort</a> <var>deferredRecord</var>'s
+   <a for="deferred fetch record">pending steps</a>.
+

There were some privacy requirements from the PendingBeacon API discussion about whether a pending beacon requests should be sent or not depending on user's periodic background sync setting for a site and the status of whether there are still same-site instances open: Details at [this PR](https://github.com/WICG/pending-beacon/pull/55/commits/feb3cf968933cebc823c4c6855d89f07bcf4005a) and [this comment](https://github.com/WICG/pending-beacon/issues/30#issuecomment-1333869614)

Should we include them here in the fetch spec as a condition?

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

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

Received on Friday, 2 June 2023 05:27:13 UTC