Anonymous-SOS Anonymous-SOS - 1 month ago 10
Javascript Question

Chrome: `fetch` takes too long

Update:



I changed the API from
fetch
to
XMLHttpRequest
and I still see the problem.

According to the console logs the delay is between "readyState 1"(i.e. OPENED) and "readyState 2"(i.e HEADERS_RECEIVED).

Also, maybe it is worth mentioning, that in Firefox it works fine.




I would appreciate a couple of pointers on how to debug why the call to
fetch()
takes 1 sec in chrome.

According to "network" tab the request took only 12ms. However in my logs and the "timeline" tab the
fetch()
takes 1.06 sec. (Screenshots below).

Any tips on how to figure out what is stalling the
fetch()
?

Network Tab screenshot:
enter image description here

Timeline Tab screenshot:
enter image description here

Answer

Turns out it was a Chrome bug that has now been fixed in Chrome 54: https://bugs.chromium.org/p/chromium/issues/detail?id=649590#c1