Re: [whatwg/fetch] Fail request when its streaming body is used in ServiceWorker (#1144)

@ricea commented on this pull request.



> @@ -3834,9 +3834,32 @@ optional <i>CORS-preflight flag</i>, run these steps:
   <p>If <var>request</var>'s <a>service-workers mode</a> is "<code>all</code>", then:
 
   <ol>
+   <li><p>Assert: <var>request</var> 's <a for=request>body</a> is either null or a
+   <a for=/>body</a>.
+
+   <li>
+    <p>Let <var>savedBody</var> be a copy of <var>request</var>'s <a for=request>body</a>.

I agree that this behaviour is unintuitive, but given that `clone()` uses `Tee()` as its underlying implementation, I can't see another reasonable solution.

Keeping the service worker alive would be bad.

The tee algorithm is running on the service worker thread, so we can't use the new stream. The tee algorithm is tied to the JavaScript realm in which it was created, due to using promises. Even if the stream is transferred away, the algorithm still has to run on the original thread.

The original stream is read from when we call `Tee()` so there's no way to put it back the way it was before the call to `clone()`.

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

Received on Wednesday, 10 February 2021 05:05:07 UTC