Issue metadata
Sign in to add a comment
|
Service worker not working for sync XMLHttpRequest
Reported by
siby.aug...@maventic.com,
Apr 19 2018
|
||||||||||||||||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36 Steps to reproduce the problem: 1.Cache files using service worker. 2.Load a XMLHttpRequest with XMLHttpRequest.open(method, url, async) with async = false 3. What is the expected behavior? It should serve from the cache via sw. What went wrong? Service worker fetch API not triggering.It's load from direct network request. Did this work before? N/A Does this work in other browsers? Yes Chrome version: 65.0.3325.181 Channel: n/a OS Version: 6.1 (Windows 7, Windows Server 2008 R2) Flash Version:
,
Apr 19 2018
Service Workers cannot intercept synchronous XHRs as that would cause a deadlock. See: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API "[Service Worker] is designed to be fully async; as a consequence, APIs such as synchronous XHR and localStorage can't be used inside a service worker." Sync XHRs have many many widely documented drawbacks and result in bad user experience. Don't use them. https://blogs.msdn.microsoft.com/wer/2011/08/03/why-you-should-use-xmlhttprequest-asynchronously/
,
Apr 19 2018
The spec requires service worker to intercept sync XHR, although we can't do it yet because of the deadlock you mention. I agree that sync XHR cannot be used inside the service worker itself, and that it's a deprecated API anyway.
,
Apr 20 2018
But SW is interrupting sync XHR on firefox browser.If it won't then existing many implementations needs to adopt async.
,
Apr 23 2018
c#4: yes fixing this is tracked at issue 602051. |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by vamshi.kommuri@chromium.org
, Apr 19 2018