NekR / offline-plugin

Offline plugin (ServiceWorker, AppCache) for webpack (https://webpack.js.org/)
MIT License
4.52k stars 294 forks source link

Caching fails to download assets in Chrome 85 #486

Open jampy opened 4 years ago

jampy commented 4 years ago

As stated here, Chrome now dislikes lots of parallel fetch() invocations unless the response body is consumed.

This practically prevents the initial download of the offline-plugin cache and also consequent updates. The Service Worker fails to install.

It's stuck in this status and fails after 10 minutes or so:

image

It took me a whole day to track down the problem to this code: https://github.com/NekR/offline-plugin/blob/master/src/misc/sw-template.js#L605

I don't want to say that the code is wrong but due to the behavior of Chrome the Promise.all() must be changed so that fetch() and cache.put() are done together.

I'm out of time to help you with a pull request on the master branch but here is my patched version for the 4.9.1 version: https://gist.github.com/jampy/4330e2008b09450da72a25aba2aa90be#file-sw-template-js-L629

jampy commented 4 years ago

FYI, my patch needed a little fix. Here is the better version: https://gist.github.com/jampy/635ab91e60907a7fe38fb18a1c11a94d#file-sw-template-js-L631