SSA
SSA

Reputation: 5493

Chrome 85 Service worker stuck on trying to install

Service worker is not installing anymore after chrome 85 update on my web application. It works fine on chrome 84 or earlier, Safari, Firefox, Microsoft Edge browser.

Tried to find the changelog or bug report but there no clear hint what can block it. Service worker endsup in error (1) after waiting for long time and in console I see many request with pending/stalled status.

However those url with pending status has path info and not static resources so for example:

For reproduction:

1.Register a service worker with global scope

  navigator.serviceWorker.register('/ServiceWorker.js', { scope: '/', updateViaCache: 'none' }).then(function (registration) {
});

2. Attach install event which looks like

self.addEventListener('install', function(event) {
  event.waitUntil(
    caches.open(cacheName).then(function(cache) {
      return cache.addAll(
        [
          '/css/bootstrap.css',
          '/css/main.css',
          '/js/bootstrap.min.js',
          '/js/jquery.min.js',
          '/offline.html',
          '/path/subpath/par1/par2'
          '/path/subpath/par1/par3'
          '/path/subpath1/par4/par5'
        ]
      );
    })
  );
});

3. Following request url (non static resources) will never complete and install will stuck on trying to install and eventully, in error/redudndant.

'/path/subpath/par1/par2'
'/path/subpath/par1/par3'
'/path/subpath1/par4/par5'

These are the only finding I can notice.

Any clue? What is changed in chrome 85 service worker / Fetch api which can cause this behaviour.

Upvotes: 3

Views: 4080

Answers (2)

Riad BZ
Riad BZ

Reputation: 11

I figured out the same issue and confirm the limit of 3 requests throttling using "cache.addAll".

It seems to be related to the cache control. I resolved that after removing the "no-store" option from the Cache-Control.

Previously :

Header set Cache-Control "no-cache, no-store, must-revalidate"

After Chrome 85 :

Header set Cache-Control "no-cache, must-revalidate"

Upvotes: 1

SSA
SSA

Reputation: 5493

So after trying all kind of things, I went with into looking source code of chromium browser and discovered for some reason request throttling is enabled by default on installing service worker and that too to max 3 requests.

That throttling is causing in our case request go into stalled state and stuck on trying to install state and eventually ended up with redundant error.

There is no flag available to disable the throttling so I decided to use cache.add instead of cache.addAll with handling all the promises and voila it works. Seems this way max concurrent request are not hit and installation can continue.

Can’t report bug on chromium but hopefully some project member can look into it and at least even if they throttle, make it recoverable.

Hope this help others for time being.

Upvotes: 3

Related Questions