Sync XHR does not get intercepted by service worker |
||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36 Example URL: If you force your computer offline and issue a sync xhr request to a cached service worker route it will fail. However if you issue the exact same request with a non-sync xhr request it will correctly hit the service worker. Steps to reproduce the problem: 1. visit https://www.moji-brush.com/ 2. turn off your internet (via devtools network throttling or turn off your wifi) 3. Run this code var request = new XMLHttpRequest(); request.open('GET', '', false); request.send(null); Note how it fails.. now run this code var request = new XMLHttpRequest(); request.open('GET', '', true); request.send(null); Note how it works What is the expected behavior? sync should behave the same as non-sync What went wrong? The sync xhr request did not respect the service worker. Did this work before? N/A Chrome version: 49.0.2623.110 Channel: n/a OS Version: OS X 10.11.4 Flash Version: Shockwave Flash 21.0 r0
,
May 12 2016
,
May 12 2016
Synchronous XHR bypasses ServiceWorkers. See bug 413103 . SW is skipped for sync loads at https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/loader/resource_dispatcher_host_impl.cc&sq=package:chromium&l=1598&rcl=1463008567
,
May 12 2016
+kenjibaheux@, jakearchibald@ Tell me if this limitation is only for V1 and you have plan to relax it.
,
May 12 2016
Retitling: "service worker cache" commonly refers to the Cache Storage API, which is not the point of this issue. I'm not totally sure if this is spec'd or just something we implemented long ago.
,
May 12 2016
I just checked the spec. It seems this behavior is not specced in the Fetch Standard.
,
May 12 2016
Jake, should service worker intercept sync XHR?
,
May 12 2016
It should. Early on in Chrome's implementation, making sync XHR interceptable was really hard for some reason (caused a deadlock if memory serves), so it was intentionally skipped. Is that still the case?
,
May 12 2016
OK. Tentatively assigning horo@. Setting to P3 since this limitation has been in our impl since inception. Not sure if the deadlock would still be there... but probably since the basic architecture is still the same.
,
May 12 2016
Yes the deadlock issue is still there. In the current implementation, the resource loading logic is executed in the main thread of the renderer process even when ServiceWorker fetches resources. So if the ServiceWorker calls fetch() in the fetch event handler of the sync XHR, the deadlock happens because the main thread is blocked by the sync XHR.
,
Jun 3 2016
,
May 25 2017
Issue 726327 has been merged into this issue.
,
May 29 2017
This will be fetch-request-xhr-sync.https.html once https://codereview.chromium.org/2907443002/ lands.
,
Jun 1 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/7fdac9fc2a776ad2ed4c3df752896e0f33861b69 commit 7fdac9fc2a776ad2ed4c3df752896e0f33861b69 Author: mike <mike@mikepennisi.com> Date: Thu Jun 01 16:44:45 2017 Upstream service worker "XHR" test to WPT The original version of this test would only pass if the service worker did *not* intercept the XHR request. That behavior conflicted with the Fetch and Service Worker specification and with the test's documentation itself. Update the test to pass only if the service worker intercepts the request. In addition: - Update URLs to suitable values for the Web Platform Tests project - Add "use strict" directives to script bodies - Increase precision of "cleanup" logic scheduling - Re-name files to adhere to precent set by existing WPT tests - Catch and report errors within Promise chain rather than relying on implicit reporting of uncaught errors. BUG= 688116 , 602051 R=falken@chromium.org Review-Url: https://codereview.chromium.org/2907443002 Cr-Commit-Position: refs/heads/master@{#476324} [modify] https://crrev.com/7fdac9fc2a776ad2ed4c3df752896e0f33861b69/third_party/WebKit/LayoutTests/FlagExpectations/enable-network-service [add] https://crrev.com/7fdac9fc2a776ad2ed4c3df752896e0f33861b69/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/fetch-request-xhr-sync.https-expected.txt [add] https://crrev.com/7fdac9fc2a776ad2ed4c3df752896e0f33861b69/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/fetch-request-xhr-sync.https.html [add] https://crrev.com/7fdac9fc2a776ad2ed4c3df752896e0f33861b69/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-request-xhr-sync-iframe.html [add] https://crrev.com/7fdac9fc2a776ad2ed4c3df752896e0f33861b69/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/fetch-request-xhr-sync-worker.js [delete] https://crrev.com/1704affd92a33a48072fa0dfb0a63af1853a493a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/sync-xhr-doesnt-deadlock-iframe.html [delete] https://crrev.com/1704affd92a33a48072fa0dfb0a63af1853a493a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/sync-xhr-doesnt-deadlock.data [delete] https://crrev.com/1704affd92a33a48072fa0dfb0a63af1853a493a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/sync-xhr-doesnt-deadlock.js [delete] https://crrev.com/1704affd92a33a48072fa0dfb0a63af1853a493a/third_party/WebKit/LayoutTests/http/tests/serviceworker/sync-xhr-doesnt-deadlock-expected.txt [delete] https://crrev.com/1704affd92a33a48072fa0dfb0a63af1853a493a/third_party/WebKit/LayoutTests/http/tests/serviceworker/sync-xhr-doesnt-deadlock.html
,
Jun 28 2017
Is this being worked on? Kinda blocked by servicification?
,
Jun 29 2017
Any context for the ping? No plans to work on this specifically, except as part of the burn down for issue 678905. Likely blocked on servicification and off-main-thread fetch to avoid deadlocks, might take a lot of care to ensure absolutely no deadlock occurs, probably more trouble than this bug is worth...
,
Jul 12 2017
,
Apr 19 2018
Issue 834802 has been merged into this issue.
,
Apr 22 2018
The dead lock should be gone now.
,
Nov 2
Given yhirano@'s comment, and the fact that the tests/expectations still indicate failures ([1] and [2]), are there any plans to get this working, or not really, since the sync XHR is deprecated? (Asking because I'm writing resource load priority layout tests for requests passing through SWs). [1]: https://wpt.fyi/results/service-workers/service-worker/fetch-request-xhr-sync.https.html?aligned&label=stable [2]: https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/fetch-request-xhr-sync.https-expected.txt?q=fetch-request-xhr-s&sq=package:chromium&g=0&l=1
,
Nov 7
I think we should fix this: sync XHR should go to the service worker. In fact it might just work automatically now if we remove the blocking per yhirano's comment. Would you be interested in taking this?
,
Nov 7
Will take a look.
,
Dec 13
Dominic do you have time to look at this? If not I might try to make a patch. Possibly if we just remove this things may work: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/loader/fetch/fetch_parameters.cc?l=110&rcl=7a3fba9b1e3a9b010b84faa8a41ad8a7baea035e This also affects sync XSLT imports at: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/xml/xsl_style_sheet_libxslt.cc?l=232&rcl=7a3fba9b1e3a9b010b84faa8a41ad8a7baea035e
,
Dec 13
,
Dec 13
Yep, just finished finals - thanks for the ping looking now.
,
Dec 14
,
Today
(12 hours ago)
Just a status update: we found at https://chromium-review.googlesource.com/c/chromium/src/+/1376738 there is probably still a deadlock/livelock somewhere.
,
Today
(12 hours ago)
|
||||||||||||||||
►
Sign in to add a comment |
||||||||||||||||
Comment 1 by yhirano@chromium.org
, Apr 11 2016