Re: [w3c/ServiceWorker] Have "Handle Fetch" return the request body in addition to response (#1563)

@annevk commented on this pull request.



>        1. If |activeWorker|'s <a>state</a> is "`activating`", wait for |activeWorker|'s <a>state</a> to become "`activated`".
       1. If the result of running the [=Run Service Worker=] algorithm with |activeWorker| is *failure*, then set |handleFetchFailed| to true.
       1. Else:
           1. Set |workerRealm| to the [=relevant realm=] of the |activeWorker|'s [=service worker/global object=].
           1. Set |eventHandled| to [=a new promise=] in |workerRealm|.
           1. [=Queue a task=] |task| to run the following substeps:
               1. Let |e| be the result of <a>creating an event</a> with {{FetchEvent}}.
+              1. If |requestBody| is not null, then:
+                  1. Set |requestBody|'s [=Body/stream=] to the result of [=ReadableStream/create a proxy|creating a proxy=] for |requestBody|'s [=Body/stream=].

It became a problem when we added streams. I think now would be a good time to solve it.

And what I mean is that if body is a stream with a null source, service workers needs to transfer ownership back to fetch, such that invoking `req.text()` will start failing afterwards. Presumably this applies to all cases where we return null.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1563#discussion_r572085960

Received on Monday, 8 February 2021 14:25:56 UTC