New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 823392 link

Starred by 25 users

Issue metadata

Status: Fixed
Owner:
Closed: Nov 30
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Opening Devtools triggers "only-if-cached" request which cannot be handled by Service Worker

Reported by aditya.p...@gmail.com, Mar 19 2018

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36

Steps to reproduce the problem:
1. Go to instagram.com (logged-in)
2. Open Devtools
3. See error "Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode"

What is the expected behavior?
Unclear to me why devtools is making this request. Seems like a regression. 

What went wrong?
Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode

Did this work before? Yes 

Chrome version: 65.0.3325.162  Channel: stable
OS Version: OS X 10.13.3
Flash Version: 

Reference: https://github.com/paulirish/caltrainschedule.io/issues/49
 
Labels: Needs-Bisect Needs-Triage-M65
Cc: krajshree@chromium.org
Labels: Triaged-ET Needs-Feedback
Unable to reproduce the issue on mac 10.13.3 using chrome reported version #65.0.3325.162 and latest canary #67.0.3375.0.

Attached a screen shot for reference.

Following are the steps followed to reproduce the issue.
------------
1. Opened instagram.com and logged-into it.
2. Opened Dev tools.
3. Did not observe any error in the console.

reporter@ - Could you please check the issue on latest canary #67.0.3375.0 by creating a new profile without any apps and extensions and please let us know if the issue still persist or not.

Thanks...!!
823392.png
1.3 MB View Download
Sorry, Instagram Service Worker might be behind an A/B. Another way to repro this is https://airhorner.com/

1. Make sure you clear the existing cache storage/service worker.
2. Open https://airhorner.com/
3. Open Devtools. 

Able to reproduce on Version 67.0.3376.1 (Official Build) canary (64-bit)
Screen Shot 2018-03-20 at 2.55.39 PM.png
94.4 KB View Download
Project Member

Comment 4 by sheriffbot@chromium.org, Mar 20 2018

Labels: -Needs-Feedback
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
Labels: Needs-Feedback
Unable to reproduce the issue on mac 10.13.3 using chrome version #67.0.3376.1.

Attached a screen cast for reference.

Following are the steps followed to reproduce the issue.
------------
1. Cleared the existing cache storage and service worker from application tab of dev tools.
2. Opened https://airhorner.com/
3. Opened Devtools. 
4. Did not observe any error logged in console, rather service worker got registered.

reporter@ - Could you please check the attached screen cast and please let us know if anything missed from our end.

Thanks...!!
823392.mp4
1.1 MB View Download
@krajshree@chromium.org, looks like you cleared the site data on the new tab page, not on the airhorner.com domain. Could you repeat the test but following these exact steps.  

1. Go to https://airhorner.com/, make sure Service Workers are registered.
2. Open Devtools -> Application tab, right click on "Cache Storage" under "Cache" and refresh caches.
3. Close devtools. 
4. Close tab.
5. Open https://airhorner.com/ and open devtools to see the error. 

Project Member

Comment 7 by sheriffbot@chromium.org, Mar 22 2018

Labels: -Needs-Feedback
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
Labels: -Needs-Bisect
Unable to reproduce the issue on mac 10.13.3 using chrome stable #65.0.3325.181 and latest canary #67.0.3378.0.

Attached a screen cast for reference.

Following are the steps followed to reproduce the issue.
------------
1. Navigated to https://airhorner.com/, and made sure Service Workers are registered.
2. Opened Devtools -> Application tab, right clicked on "Cache Storage" under "Cache" and refreshed caches.
3. Closed devtools. 
4. Closed tab.
5. Opened https://airhorner.com/ and did not find any error in console rather showed as Service Worker Ready
Service Worker Registered

Removing Needs-Bisect label as the issue is not reproducible from TE-end and requesting someone from Platform>DevTools team to please have a look into the issue.

Thanks...!!
823392@M65.mp4
872 KB View Download

Comment 9 by l...@chromium.org, Apr 2 2018

Owner: eostroukhov@chromium.org
Status: Assigned (was: Unconfirmed)
I was able to reproduce only after manually selecting each item in Cache Storage and clearing with the "Clear selected" 'x' toolbar button.  Reproduces in Chrome, but not Firefox.


@eostroukhov@chromium.org I am still able to reproduce this on the latest version of Chrome. 
I have the same issue and can reproduce on Chrome version 66.0.3359.181 (Official Build)(64-bit) and Chrome Version 68.0.3437.1
Someone just reported this issues here as well: https://github.com/NekR/offline-plugin/issues/385

Is this devtools only issue? How can it affect users? Should every service-worker library silent this error until it's being fixed in the browser?

Thanks.
Getting same error for me with workbox plugin v3. 
i am also getting the same error in https://wwww.ujjawalpackers.in
Owner: hhli@chromium.org
Components: Blink>ServiceWorker
Cc: swarnasree.mukkala@chromium.org
 Issue 899192  has been merged into this issue.
One theory is DevTools is creating this request in order to get resource information for view-source. Maybe here:
https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/inspector/inspector_resource_content_loader.cc?l=84&rcl=ab49452b3e9d18fe8edf23a8dae63a797c6b6da2

This likely causes the console error on sites whose service workers do event.respondWith(fetch(event.request)) when event.request is cross-origin.

One option could be to skip service workers for this request by calling resource_request.SetSkipServiceWorker(true).
Or maybe we could make that request use the "same-origin" mode so its legal per the fetch spec.  In theory the fetch spec says the platform shouldn't be able to make such a request at all.

Comment 20 Deleted

Same issue here. evt.respondWith(fetch(request)); triggers
Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'ServiceWorkerGlobalScope': 'only-if-cached' can be set only with 'same-origin' mode

Just trying to intercept request to add auth tokens.
c#19: I thought that might break for cross-origin resources, but yea worth exploring.
Owner: jarhar@chromium.org
Status: Started (was: Assigned)
Project Member

Comment 25 by bugdroid1@chromium.org, Nov 28

Won't the fix in #c25 run into problems on sites that in some way generate different css from the service worker compared to the network?  It seems like devtools might show different css from what the page is actually running with.

One possible fix would be to generate go to service worker for same-origin stylesheets and set mode:same-origin in fetch() so the error is not hit.  For cross-origin stylesheets skipping the service worker may just be necessary since only-if-cached is not supported for content in that case.
wanderview@ I see, since the service worker could change the responses of requests we send we should go through it when we can. I will look into it.
Project Member

Comment 28 by bugdroid1@chromium.org, Nov 30

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/145c32ab33ab879ecacfa039dc4ce832bbf790d4

commit 145c32ab33ab879ecacfa039dc4ce832bbf790d4
Author: Joey Arhar <jarhar@chromium.org>
Date: Fri Nov 30 01:47:21 2018

[DevTools] Make css enable fetch compatible with service workers

This is a replacement for the fix made in
https://chromium-review.googlesource.com/c/chromium/src/+/1350170
which uses the same-origin mode instead of bypassing service workers in
order to make sure changes made by the service worker get into devtools
properly.

Bug:  823392 
Change-Id: I7773a0281d52ebeddc1aa3b9facb7353f7fd1dcc
Reviewed-on: https://chromium-review.googlesource.com/c/1353991
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612491}
[modify] https://crrev.com/145c32ab33ab879ecacfa039dc4ce832bbf790d4/third_party/blink/renderer/core/inspector/inspector_resource_content_loader.cc
[modify] https://crrev.com/145c32ab33ab879ecacfa039dc4ce832bbf790d4/third_party/blink/web_tests/http/tests/inspector-protocol/service-worker/intercept-css-enable-fetch-expected.txt
[modify] https://crrev.com/145c32ab33ab879ecacfa039dc4ce832bbf790d4/third_party/blink/web_tests/http/tests/inspector-protocol/service-worker/intercept-css-enable-fetch.js
[modify] https://crrev.com/145c32ab33ab879ecacfa039dc4ce832bbf790d4/third_party/blink/web_tests/http/tests/inspector-protocol/service-worker/resources/repeat-fetch-service-worker.js

Status: Fixed (was: Started)
Thanks for the help wanderview@ and falken@

Sign in to add a comment