New issue
Advanced search Search tips

Issue 834802 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 602051
Owner: ----
Closed: Apr 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Service worker not working for sync XMLHttpRequest

Reported by siby.aug...@maventic.com, Apr 19 2018

Issue description

UserAgent: 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:
 
Labels: Needs-Triage-M65
Status: WontFix (was: Unconfirmed)
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/

Comment 3 by falken@chromium.org, Apr 19 2018

Mergedinto: 602051
Status: Duplicate (was: WontFix)
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.
But SW is interrupting sync XHR on firefox browser.If it won't then existing many implementations needs to adopt async.

Comment 5 by falken@chromium.org, Apr 23 2018

c#4: yes fixing this is tracked at issue 602051.

Sign in to add a comment