Re: [whatwg/fetch] Copy priority so service worker pass-through requests don't lose it (#785)

After taking a closer look at Chrome's implementation and the spec, I'm wondering if copying over [priority](https://fetch.spec.whatwg.org/#concept-request-priority) is enough? We never explicitly set the priority concept, instead we just tell the implementation to generate it, given [destination](https://fetch.spec.whatwg.org/#concept-request-destination) and [initiator](https://fetch.spec.whatwg.org/#concept-request-initiator), in [concept fetch](https://fetch.spec.whatwg.org/#concept-fetch) > 1 > 5.

With this, I'm thinking we might not solve the problem at hand by copying over priority, because the destination and initiator will not be preserved, and the priority will just be re-generated in the later concept fetch steps to what it would have been if we never preserved priority. I'm wondering if we'd be better off copying over the destination and initiator, but we should also confirm that this doesn't break anything.

----
With the current PR, imagine the steps below in action:

1. We [obtain](https://html.spec.whatwg.org/multipage/semantics.html#obtaining-a-resource-from-a-link-element) a `<link rel=preload as=style href=dom.css>` (which explicitly sets the request's destination)
2. The request is fetched, and its priority is generated in [fetch](https://fetch.spec.whatwg.org/#concept-fetch) > 1 > 5
3. The request goes through a Service Worker that does `event.respondWith(fetch(event.request))`
4. Since [`fetch()`](https://fetch.spec.whatwg.org/#fetch-method) will call the Request() constructor, we'll lose our destination and initiator concepts, but preserve our priority
5. [`fetch()`](https://fetch.spec.whatwg.org/#fetch-method) calls [fetch](https://fetch.spec.whatwg.org/#concept-fetch) (ikr) and goes back through steps 1 > 5, resetting our preserved priority, given the default destination ("") and initiator ("")
6. It is as if we never saved our priority

Disclaimer: entirely possible I'm missing something here

-- 
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/785#issuecomment-412253141

Received on Saturday, 11 August 2018 05:41:03 UTC