pace icon indicating copy to clipboard operation
pace copied to clipboard

Synchronous AJAX requests are deprecated warning

Open kenny1983 opened this issue 8 years ago • 9 comments

When refreshing a page via a top-level document.write(), I get the following warning in Chrome Developer Tools:

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

So I was simply wondering where and why synchronous AJAX requests are used within pace. As the warning suggests, this is generally considered bad behaviour, and I suggest that you guys find a workaround ASAP.

kenny1983 avatar Oct 17 '16 13:10 kenny1983

I am having the same problem. I believe that it has to do with the XMLHttpRequest.open(). As noted here https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open, shows that...

Note: Starting with Gecko 30.0 (Firefox 30.0 / Thunderbird 30.0 / SeaMonkey 2.27), synchronous requests on the main thread have been deprecated due to the negative effects to the user experience.

In pace.js I have tried to add the parameter on line 428 _this.trigger('request', { type: type, url: url, request: req, async: true });

and on line 434 return _open.apply(req, arguments, true);

But have had no luck. Anyone have any other ideas?

SilverSlug avatar Oct 17 '16 22:10 SilverSlug

also having this issue.

kmeado avatar Oct 19 '16 17:10 kmeado

also still has a same open issue #199.

john20xdoe avatar Dec 15 '16 08:12 john20xdoe

Check if your AJAX call is set to false (async: false), if not then the chances are that you have some extensions running on your browser that do a synchronous call back. Easy way to identify is to open the console in Chrome, enable "Log XMLHttpRequests" and you will be able to see the extension that is causing the issue to be reported. Hope this helps.

sujitswaroop avatar May 29 '17 10:05 sujitswaroop

@sujitswaroop Changed from Pace JS 1.0.0. to 0.7.8. version, however I don't see any difference. In fact my Crome console is pointing now to the line return _open.call(req, type, url, async);

In both case I get similar warning: [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

Is there any permanent solution for this, please?

matissg avatar Aug 16 '17 05:08 matissg

I just tried 1.0.2 and have this issue as well

dyardyGIT avatar Oct 26 '17 21:10 dyardyGIT

For me this was happening in the context of doing AJAX(XMLHttpRequest) calls in a Chrome extension js file and I was able to fix the issue with passing true as third parameter when I did:

xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", endPoint, true);

hlawuleka avatar Sep 08 '18 14:09 hlawuleka

In the error message you will find the document of the "XMLHttpRequest"

At the 1/6 of the page (scroll down) you will find this:

Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user’s experience. (This is a long process that takes many years.) Developers must not pass false for the async argument when current global object is a Window object. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing an "InvalidAccessError" DOMException when it occurs.

long way, but you better use to use Service Workers

https://developers.google.com/web/fundamentals/primers/service-workers/

atedin avatar Dec 10 '18 22:12 atedin

Thanks Hlawuleka I had Async set to FALSE for some reason....

xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", endPoint, false);

Sseriously avatar Sep 27 '19 17:09 Sseriously