工作箱后台同步:找不到指定的对象存储库之一

时间:2018-11-23 18:48:55

标签: service-worker workbox background-sync

通过backgroundSync插件发送PUT请求时,我得到以下信息:

workbox-core.prod.js:1 Uncaught (in promise) DOMException: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
    at https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-core.prod.js:1:3663
    at new Promise ()
    at https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-core.prod.js:1:3625
    at Generator.next ()
    at n (https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-core.prod.js:1:167)
    at https://storage.googleapis.com/workbox-cdn/releases/3.6.3/workbox-core.prod.js:1:261

我添加路线的方式如下:

    workbox.routing.registerRoute(
        new RegExp(`^${location.origin}\/vault\/`),
        workbox.strategies.networkOnly({
            plugins: [
                new workbox.backgroundSync.Plugin('vault', {
                    maxRetentionTime: 48 *60 // Retry time
                }),
            ],
        }),
        'PUT'
    )

这是触发请求的代码: fetch('/vault/xxx123.jpg', {method: 'PUT'})

IndexedDB确实包含一个名为workbox-background-sync的数据库,但实际上其中没有存储。 我希望Workbox能够创建它,除非我在这里做错了什么?

0 个答案:

没有答案