Pass-through service worker sometimes fails due to browser-provided options
Reported by
a...@scirra.com,
Oct 26
|
|||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3591.0 Safari/537.36 Steps to reproduce the problem: Our PWA uses a Service Worker for offline support. Try it out at: https://editor.construct.net/r122 Sometimes Chrome sends a navigate fetch for the main page with the options: cache: "only-if-cached", mode: "no-cors" Sometimes our SW responds with a pass-through fetch, i.e. fetch(event.request). This then fails with: "Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode" What is the expected behavior? Chrome should not provide fetch event options that are incompatible with each other. fetch(event.request) should be a reliable way to pass through a fetch without having to first modify the options. What went wrong? It appears Chrome provided incompatible fetch options, so they would have to be changed for the fetch to succeed. Did this work before? Yes not sure Does this work in other browsers? Yes Chrome version: 72.0.3591.0 Channel: canary OS Version: 10.0 Flash Version: This does not appear to ever happen in Firefox or Edge. It is difficult to come up with reliable steps to reproduce - it doesn't seem to always happen and the general stickiness of service workers makes it hard to investigate. A few reloads in incognito mode with "Pause on caught exceptions" enabled tends to hit it, but often you have to try several times in new windows.
,
Oct 26
That error message was added here: https://chromium-review.googlesource.com/c/chromium/src/+/758376 Given that it doesn't always happen, I wonder if Chrome generates a request with these options only in certain cases. I don't know what the expected cache and mode are for a navigation.
,
Oct 29
,
Oct 29
Tested the issue on reported chrome version #72.0.3591.0 using Windows 10 by following below steps. Steps: ===== 1.Launched chrome. 2.Navigated to "https://editor.construct.net/r122". 3.Navigated to Devtools->Network tab and reloaded the page observed errors under the tab. 4.Tried searching cache: "only-if-cached" and mode: "no-cors" under console tab and network tab, but could not find them. Attached screencast for reference. @reporter: Could you please provide the screencast of the issue so that it would be really helpful for further triaging of the issue. Thanks.!
,
Oct 29
,
Oct 29
Do you actually see failure in your loaded page or are you just getting unexplained error messages in the console? I've seen something like this before. I believe its devtools trying to load the page source, etc. I think it uses only-if-cached so that it can show the last resource loaded by the page and not a potentially modified one from the server.
,
Oct 30
I'm not sure, because issue 899196 means there's tons of random failures, so it's hard to tell if this is one of them. I have definitely seen this after loading the page with dev tools closed, and then opened dev tools, and the error is in the middle of some past logs so presumably occurred some time while dev tools was closed.
,
Oct 30
Thank you for providing more feedback. Adding the requester to the cc list. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 30
BTW I can reliably reproduce this with the following steps: 1. Open a new incognito window 2. Navigate to https://editor.construct.net/r122 3. Wait a few seconds 4. Open dev tools and look at console messages I can always see the following message: Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode
,
Oct 31
Able to reproduce the issue on latest stable #70.3538.77, reported chrome version #72.0.3591.0 and latest chrome #72.0.3596.0 using Windows 10, Ubuntu 17.10 and Mac OS 14.0 by following steps as per comment #9. The behavior is seen from old M-60 builds(#60.0.3112.113). This is a non-regression issue, hence marking it as Untriaged and requesting someone from the dev team to look into the issue. Thanks.!
,
Oct 31
,
Oct 31
+correcting comment#10 in Mac OS version 10.14
,
Nov 2
If 'only-if-cached' message is a red herring due to DevTools I think we should fix DevTools to not show it. It's confusing debugging and triaging these issues. OTOH it's strange that if this happened since M60 and no one noticed before.
,
Nov 2
I think I've seen the same bug / issues before, issue 823392 looks same?
,
Nov 2
|
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by a...@scirra.com
, Oct 26