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

@mingyc commented on this pull request.



> + </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}}.
+
+ <li><p>Set <var>request</var>'s <a for=request>keepalive</a> to true.

```
Set request's keepalive to true.
```

It looks like the existing step to throw `TypeError` to prevent requestBody being a ReadableStream when `keepalive==true` does not apply to the new algorithm? Setting either it's too late to set it here, or we need to specify "To extract a body with type " (not [safely extract](https://whatpr.org/fetch/1647/53e4c3d...71fd383.html#bodyinit-safely-extract)) for our DeferredRequestInit.


The `set keepalive` step is in `Deferred fetching` algorithm, which happens after

```
Let requestObject be the result of invoking the initial value of [Request] as constructor with input and init as arguments.
``` 
, which looks like it only performs `safely extracted` algorithm:

```
A request has an associated body (null, a [byte sequence], or a [body]).
A byte sequence will be [safely extracted] into a [body ] early on in [fetch]
```

But a safely extracted body does not throw any error by its spec.


Also, even after the above step setting `keepalive=true`, looking into the last step when deferred fetching happens when fetchGroup is deactviated:

```
Fetch record’s request
```

The `Fetch` also points to the algorithm that uses safely extracted body:

```
If request ’s [body ] is a [byte sequence ], then set request ’s [body ] to request ’s [body ] [as a body ].

...

=> To get a [byte sequence ] bytes as a body , return the [body ] of the result of [safely extracting ] bytes .
```

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

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

Received on Tuesday, 29 August 2023 03:45:43 UTC