w3c / ServiceWorker

Service Workers
https://w3c.github.io/ServiceWorker/
Other
3.63k stars 313 forks source link

respondWith creates JS objects in parallel #1170

Open bzbarsky opened 7 years ago

bzbarsky commented 7 years ago

https://w3c.github.io/ServiceWorker/v1/#fetch-event-respondwith step 10.3.1.2.5.5 says:

Let newStream be the result of construct a ReadableStream object with strategy, pull and cancel in targetRealm.

and links to https://fetch.spec.whatwg.org/#concept-construct-readablestream. But it doesn't properly set up current Realms (though it does at least hint as to what the current Realm should be set up to). Worse yet, this entire part of respondWith is "in parallel", so it can't do object creation to start with.

bzbarsky commented 7 years ago

@domenic @wanderview

domenic commented 7 years ago

As far as I can tell respondWith shouldn't be running in parallel at all.

bzbarsky commented 7 years ago

Note that targetRealm is not the current realm of the respondWith call, so if the intent is that we have it as a current realm there is more to be done here no mattter what.

wanderview commented 7 years ago

I wrote a little bit about how an implementation might implement respondWith() using a js ReadableStream in https://github.com/w3c/ServiceWorker/issues/1168#issuecomment-317031289 and https://github.com/w3c/ServiceWorker/issues/1168#issuecomment-317032758. In theory we could write the spec language in a similar way.