service-worker

Failed to register a ServiceWorker: ServiceWorker cannot be started

坚强是说给别人听的谎言 提交于 2020-08-22 09:58:48
问题 Everything was working fine with my Service Worker project, but suddenly I am seeing the following error: Uncaught (in promise) DOMException: Failed to register a ServiceWorker: ServiceWorker cannot be started This is being reported as on index.html:1 although I am registering the SW in a file called sw.js. I couldn't find anything on Google - any guidance on what causes this error to occur? 回答1: So it turns out this just indicates there is a JS error in the Service Worker code itself, so the

Failed to register a ServiceWorker: ServiceWorker cannot be started

青春壹個敷衍的年華 提交于 2020-08-22 09:58:47
问题 Everything was working fine with my Service Worker project, but suddenly I am seeing the following error: Uncaught (in promise) DOMException: Failed to register a ServiceWorker: ServiceWorker cannot be started This is being reported as on index.html:1 although I am registering the SW in a file called sw.js. I couldn't find anything on Google - any guidance on what causes this error to occur? 回答1: So it turns out this just indicates there is a JS error in the Service Worker code itself, so the

Failed to register a ServiceWorker: ServiceWorker cannot be started

天涯浪子 提交于 2020-08-22 09:58:10
问题 Everything was working fine with my Service Worker project, but suddenly I am seeing the following error: Uncaught (in promise) DOMException: Failed to register a ServiceWorker: ServiceWorker cannot be started This is being reported as on index.html:1 although I am registering the SW in a file called sw.js. I couldn't find anything on Google - any guidance on what causes this error to occur? 回答1: So it turns out this just indicates there is a JS error in the Service Worker code itself, so the

self.skipWaiting() not working in Service Worker

风流意气都作罢 提交于 2020-08-21 19:40:19
问题 I have a service worker. Here's the install event: self.addEventListener('install', function (event) { console.log('Installing Service Worker ...', event); return self.skipWaiting() .then(() => caches.open(CACHE_STATIC_NAME)) .then(function (cache) { return cache.addAll([ './file1.html', './file2.html' ]) }) }); For some reason, when I edit the service worker code and update the query parameter in the service worker file URL, it installs but does not activate (according to Chrome DevTools) —

self.skipWaiting() not working in Service Worker

旧巷老猫 提交于 2020-08-21 19:37:11
问题 I have a service worker. Here's the install event: self.addEventListener('install', function (event) { console.log('Installing Service Worker ...', event); return self.skipWaiting() .then(() => caches.open(CACHE_STATIC_NAME)) .then(function (cache) { return cache.addAll([ './file1.html', './file2.html' ]) }) }); For some reason, when I edit the service worker code and update the query parameter in the service worker file URL, it installs but does not activate (according to Chrome DevTools) —

I'm trying to make use of the service worker in create-react-app but I keep getting…wont register sw. Current env: development

岁酱吖の 提交于 2020-07-23 11:40:28
问题 I'm using create-react-app but the service worker isnt working. Im using localhost I'm trying to make this a PWA, i'm using the stock manifest file and service worker generated when you create-react-app, i've also rand npm run-script build and got the generated service-worker.js file. The problem is that I keep getting this in the console. wont register sw. Current env: development help? window.addEventListener("load", () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; if