Bug 190041 - Safari refuses to open pages with workbox due to “service worker redirection error”.
Summary: Safari refuses to open pages with workbox due to “service worker redirection ...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: Other
Hardware: iPhone / iPad Other
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-09-27 09:56 PDT by srikarocks
Modified: 2019-01-04 10:06 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description srikarocks 2018-09-27 09:56:31 PDT
I was using iOS 12 which is not available as an option currently.

On websites which use workbox for service workers cannot be opened due to an error titled “Response served by service worker has redirections”. I first ran into this error on https://v8.dev which uses workbox. The v8 team, which wrote the website, confirmed on GitHub https://github.com/v8/v8.dev/issues/4 that no redirects are used on the homepage.

More details about this issue are on https://github.com/v8/v8.dev/issues/4

Instructions to reproduce:

Turn on service workers: Settings>Safari>Advanced>Experimental Features>ServiceWorker>ON.

1. Visit a workbox site (https://v8.dev) and bookmark the site
2. Close the tab and then close the browser
3. Reopen safari and open the bookmark. If the error doesn’t appear, repeat this step.
Comment 1 Radar WebKit Bug Importer 2018-09-28 16:18:42 PDT
<rdar://problem/44878311>
Comment 2 youenn fablet 2018-09-29 00:58:58 PDT
I reproduced the issue on iOS.
It might be that we are incorrectly computing that the response is redirected, maybe we are not handling 304 correctly
Comment 3 youenn fablet 2018-09-29 02:49:44 PDT
Doing some debugging the following is happening:
- A navigate load triggers a fetch event to "https://v8.dev"
- The service worker fetches "https://v8.dev/index.html"
- "https://v8.dev/index.html" is redirected to "https://v8.dev" which gives a response
- response.redirected is set to true since there is a redirection.
- Navigation load fails since it does not expect a redirected response as per spec.

I guess the fix should be for the service worker to directly fetch "https://v8.dev".
Comment 4 Mathias Bynens 2018-09-29 05:29:17 PDT
Thanks for the info, Youenn! I’ll get the service worker fixed on our end.

FWIW, this behavior does not match Chrome‘s, where the bug does not appear. Maybe there is still some kind of browser-compat bug here.
Comment 5 youenn fablet 2018-09-29 13:46:15 PDT
> FWIW, this behavior does not match Chrome‘s, where the bug does not appear.
> Maybe there is still some kind of browser-compat bug here.

It seems so if the scripts are the same in iOS and elsewhere.
Safari MacOS works, not iOS.
On MacOS, index.html fetch event is answered by the DOM cache.
On iOS, index.html is not in the DOM cache, fetch is used and it fails.
Comment 6 youenn fablet 2018-09-30 01:51:36 PDT
(In reply to youenn fablet from comment #5)
> > FWIW, this behavior does not match Chrome‘s, where the bug does not appear.
> > Maybe there is still some kind of browser-compat bug here.
> 
> It seems so if the scripts are the same in iOS and elsewhere.
> Safari MacOS works, not iOS.

I hit this issue in MacOS as well.

> On MacOS, index.html fetch event is answered by the DOM cache.
> On iOS, index.html is not in the DOM cache, fetch is used and it fails.

When hitting this issue in MacOS, the DOM cache is also empty.
Comment 7 youenn fablet 2019-01-04 10:06:03 PST
Marking as resolved for now.