[Webkit-unassigned] [Bug 242910] New: A stopped service worker fails to pass header and referrer on fetch request
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Jul 19 11:22:40 PDT 2022
https://bugs.webkit.org/show_bug.cgi?id=242910
Bug ID: 242910
Summary: A stopped service worker fails to pass header and
referrer on fetch request
Product: WebKit
Version: Safari 15
Hardware: All
OS: All
Status: NEW
Severity: Blocker
Priority: P2
Component: Service Workers
Assignee: webkit-unassigned at lists.webkit.org
Reporter: boguinn at etsy.com
As of Safari 15.5/Webkit 613.2.7, when a service worker has just moved from "idle" to "active", any fetch requests it makes will lack custom headers and referrer.
I am able to reproduce this problem consistently via installing this sandbox service worker:
```
self.addEventListener("fetch", (event) => {
const newRequest = new Request(event.request, {
headers: { "X-My-Custom-Header": "1" },
});
event.respondWith(fetch(newRequest));
});
```
And then checking the contents of the "$_SERVER" variable on my my PHP server (or whatever equivalent you use):
```
[HTTP_HOST] => <my test server url>
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[HTTP_COOKIE] => <omitted, but looks good>
[HTTP_USER_AGENT] => Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1
[HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.9
[HTTP_ACCEPT_ENCODING] => gzip, deflate, br
[HTTP_CONNECTION] => keep-alive
[HTTP_REFERER] =>
```
And you can see that `HTTP_X_MY_CUSTOM_HEADER` is missing.
To reproduce:
1. Install the sandbox service worker I posted above.
2. Load a page and see that the custom header and referrer are sent correctly in a network request.
3. Allow the service worker to go to the idle state. Practically, this looks like closing the test domain's tab and visiting another site for roughly 10 seconds. You can check the `Develop > Service Workers` drop-down menu to see if the service worker has been idled; if it has, it will be missing from this list.
4. Re-visit your test domain and see that the new request is now missing the custom header and referrer.
5. Re-load the page and see that a page request from an active and started service worker always contains the custom header and referrer.
Thanks for your help, and let me know whatever other info you need to debug. This is a blocking bug for Etsy's use of service workers.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220719/d2fe5f73/attachment-0001.htm>
More information about the webkit-unassigned
mailing list