工作箱 serviceworker 在除 Chrome 之外的任何地方工作:未捕获(承诺)DOMException [英] workbox serviceworker working everywhere except Chrome: Uncaught (in promise) DOMException

查看:32
本文介绍了工作箱 serviceworker 在除 Chrome 之外的任何地方工作:未捕获(承诺)DOMException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Workbox 不适用于 Chrome,但它适用于其他任何地方,这很讽刺,因为我相信这是一个谷歌图书馆,显示的错误是:

Workbox is not working on Chrome, but it works everywhere else, which is ironic since I believe this is a Google library, the error that shows is :

Uncaught (in promise) DOMException : sw.js line 1

铬:

歌剧

火狐

我正在使用 workbox-webpack-plugin

I'm using the workbox-webpack-plugin

webpack.config.js

webpack.config.js

    const workbox = require('workbox-webpack-plugin'); 

    module.exports = {
        plugins: [
            new workbox.GenerateSW({
                swDest: './service-worker.js',
                skipWaiting: true,
                clientsClaim: true
            })
        ]  
 }

index.ts(入口)

index.ts (entry)

if ('serviceWorker' in navigator) {
  window.addEventListener('load', function() {
    navigator.serviceWorker.register('/js/app/dist/service-worker.js');
  }); 
}

这是引发错误的代码行

编辑 2:它实际上适用于 icognito 模式,删除浏览器数据仍然无济于事.

EDIT 2: it actually works on icognito mode, removing browser data still doesn't help.

编辑 3:更新到最新的 beta 1 甚至更糟,因为除了最后一个错误之外,它还会显示另一个错误,但是,此版本也适用于 Chrome 的 icognito 模式和其他浏览器.

EDIT 3: Updating to the newest beta 1, is even worse, since aside from the last errors it will show another one, however, this version works in Chrome's icognito mode and other browsers too.

推荐答案

如果浏览器分配的磁盘空间配额不足,通常会​​抛出此错误.您的隐身模式正在运行,因为它将分配新的磁盘配额,而普通选项卡共享相同的磁盘配额.

This error is usually thrown if the browser is out of allocated disk space quota. Your incognito is working because it will be allocated with new disk quota, where as normal tabs share same disk quota.

你能在devtools中打开Application标签并点击Clear storage>吗?清除网站数据?在大多数情况下,这应该可以解决此问题.

Can you open Application tab in devtools and click on Clear storage > Clear site data? This should fix this issue in most of the cases.

这篇关于工作箱 serviceworker 在除 Chrome 之外的任何地方工作:未捕获(承诺)DOMException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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