Re: Service worker cache.addAll fetch pending, stuck on trying to install

764 views
Skip to first unread message

Kenichi Ishibashi

unread,
Sep 2, 2020, 7:46:21 PM9/2/20
to Sandeep Sharma, worke...@chromium.org, shi...@chromium.org
+work...@chromium.org, shi...@chromium.org

Thank you for the report. Would you mind trying to file the issue on crbug.com again? I guess the failure was tentative.

shimazu@: Do you think offline capability checks could be related to this?

On Wed, Sep 2, 2020 at 12:50 AM Sandeep Sharma <deepbh...@gmail.com> wrote:
Hi Bashi,

Don't know if this is the right channel to ask for help or report service worker but got your email address from a colleague. Excuse for bothering you otherwise.

Here is the summary of issue I am facing with latest Chrome 85 release. I tried to submit a new issue  on chromium bug site but no luck, 400 bad response on submit.

Issue: Service worker cache.addAll fetch pending, stuck on trying to install

Step to reproduce:


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 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'


Expeced behaviour:
  
Just like earlier version chrome 85* should also work until and unless there a reason/security thing* for failure which should be indicated as an error/warning. PWA is running fine since last 2 year and we have not made any changes.


Explanation/Analysis: 
 
Service worker install event never succeed anymore after chrome 85 update on my web application. It works fine on chrome 84 or earlier, Safari, Firefox, Microsoft Edge browser.

Service worker endsup in error (1)/Redundant after trying to install for long time and in console I see many fetch request with pending status/stalled.

However most of those url with pending status has path info and are extension less urls and not static resources.

For example, when install event triggers, it gets an array of url's


https://xyz.com/path/test1.js ==> Fetch completed

https://xyz.com/path/test2.js ==> Fetch completed

https://xyz.com/path/image.jpg ==> Fetch completed

https://xyz.com/path/image2.jpg ==> Fetch completed

https://xyz.com/path/subpath/par1/par2 ==> Fetch completed

and then stalled ones appears, which never completes

https://xyz.com/path/subpath/par3/par4 ==> Fetch pending/stalled

https://xyz.com/path/subpath/par4/par5 ==> Fetch pending/stalled

and then again some completed ones

https://xyz.com/path/test.js ==> Fetch completed

In HAR fetch call, completed and failed request looks like this:

Fetch success:

fetch("https://xyz.com/FG/Index/1/TEST", {
  "headers": {
    "accept": "*/*",
    "accept-language": "en,nl;q=0.9",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin"
  },
  "referrer": "https://xyz.com/ServiceWorker",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": null,
  "method": "GET",
  "mode": "cors",
  "credentials": "include"
});

Pending/Stalled:

fetch("https://xyz.com/FG/Index/2/TEST1", {
  "referrer": "https://xyz.com/ServiceWorker",
  "referrerPolicy": "strict-origin-when-cross-origin",
  "body": null,
  "method": "GET",
  "mode": "cors",
  "credentials": "omit"
});


In my analysis, all static server resources works fine, *.js, *.css, *.jpg . So if I remove non static links service worker install correctly and all works fine.

Could you please point me right direction, how can I can connect on right channel about this issue. Thanks 


--
Regards,
S. Sharma

Sandeep Sharma

unread,
Sep 2, 2020, 9:18:28 PM9/2/20
to Kenichi Ishibashi, shi...@chromium.org, worke...@chromium.org
Thanks for the reply Kenichi, I’ll try again meanwhile after trying all kind of things, I went with into looking source code of chromium browser and discovered that,  for some reason request throttling is enabled by default on installing service worker in this version 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.

Behavior is very likely to happen with large cache and requests that takes a little longer to response.

Thanks,

Sandeep Sharma


--
Regards,
Sandeep Sharma

Kenichi Ishibashi

unread,
Sep 2, 2020, 9:22:27 PM9/2/20
to Sandeep Sharma, shi...@chromium.org, worke...@chromium.org, wande...@chromium.org
Thank you for the update, Sandeep! +wande...@chromium.org for addAll() vs add().

Makoto Shimazu

unread,
Sep 2, 2020, 10:06:44 PM9/2/20
to Kenichi Ishibashi, Sandeep Sharma, Makoto Shimazu, worke...@chromium.org, Ben Kelly
Hi Sandeep,

Thanks for reporting the issue. 
I think it'd be nicer if you could try to file an issue in crbug again because we can continue the discussion in a public space where more people watch. (Sorry for asking it multiple times! It's important to keep track of issues there, so that we don't miss it.)

Regarding OfflineCapabilityCheck, I don't think it's related because the issue happens on installing workers. Installing workers don't get fake fetch events for the offline capability check.
Regarding the throttling, I don't think there are any differences between add() and addAll() because they are exactly the same internally. addAll() just calls fetch() for all urls, waits for Promise.all() for them, and put() for the responses.
If it matters, that sounds like there's something we don't expect.

I'd appreciate it if you could provide a sample site which is simplified to reproduce the issue.

Thanks!
Makoto

2020年9月3日(木) 10:22 Kenichi Ishibashi <ba...@chromium.org>:

Sandeep Sharma

unread,
Sep 3, 2020, 4:29:43 AM9/3/20
to Makoto Shimazu, Kenichi Ishibashi, worke...@chromium.org, Ben Kelly
Guys, thank you very much for your prompt responses. I have filed a report https://bugs.chromium.org/p/chromium/issues/detail?id=1124632 ;

Let's follow the discussion there. I have added as many details as possible, I can collect more logs but I am afraid if I can set a test site easily. 

--
Regards,
Sandeep Sharma

Ben Kelly

unread,
Sep 3, 2020, 11:26:12 AM9/3/20
to Sandeep Sharma, Makoto Shimazu, Kenichi Ishibashi, worker-dev
FYI, I have disabled the throttling feature while I work on a fix for cache.addAll().  Sorry for the issue and thanks for the report.

Sandeep Sharma

unread,
Sep 3, 2020, 11:29:42 AM9/3/20
to Ben Kelly, Makoto Shimazu, Kenichi Ishibashi, worker-dev
Hi Ben,

That's really quick action. Heartily appreciate it. Thank you.

Best regards,
Sandeep
--
Regards,
Sandeep Sharma
Reply all
Reply to author
Forward
0 new messages