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

@annevk 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>.

It seems that an implementation could use a different implementation though that would avoid keeping the service worker alive. The document that created the request stream (originalStream) is supplying the contents. The service worker gets that stream (requestStream), clones it, keeps one for itself (clonedStream) and hands the other back to the document that created the stream in the first place (requestStream -> originalStreamProxy). It seems an implementation could structure things such that at this point originalStreamProxy gets its contents directly from originalStream and originalStreamProxy gets them from originalStream as well.

I'm not exactly sure where the promises come in here, but it seems that for things that happen in the service worker there is only one realm to chose from and those in the document cannot use the realm from the service worker either.

-- 
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_r573473097

Received on Wednesday, 10 February 2021 06:13:27 UTC