Chrome 85服务人员无法尝试安装 [英] Chrome 85 Service worker stuck on trying to install

查看:79
本文介绍了Chrome 85服务人员无法尝试安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Web应用程序上更新chrome 85之后,Service Worker不再安装.在chrome 84或更早版本,Safari,Firefox,Microsoft Edge浏览器上可以正常使用.

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.

试图找到变更日志或错误报告,但是没有明确的提示可以阻止它.服务人员等待了很长一段时间后,在错误(1)中结束,在控制台中,我看到许多请求处于待处理/已停止状态.

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.

但是状态为待定的那些url具有路径信息,而不是静态资源,例如:

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

为了复制:

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.

有任何线索吗? chrome 85服务人员/提取api中发生的更改会导致此行为.

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

推荐答案

因此,在尝试了所有方法之后,我着手研究了Chrome浏览器的源代码,发现由于某种原因,在安装Service Worker时默认情况下启用了请求限制最多也有3个请求.

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.

没有可用于禁用限制的标志,因此我决定使用cache.add代替cache.addAll与 兑现所有诺言,并保证它奏效.似乎这种方式不会达到最大并发请求,并且安装可以继续.

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.

这篇关于Chrome 85服务人员无法尝试安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆