I am trying to audit my application on Chrome Lighthouse, but I can't get Service Worker working. It is registered and running with no error, but when I try to run Lighthouse it gets stuck and console log the fallowing error:
Service worker not registered DOMException: Failed to register a ServiceWorker for scope ('https://www.localhost.com/') with script ('https://www.localhost.com/sw.js'): Operation has been aborted
SW is called with:
if('serviceWorker' in navigator){
let sw = 'sw.js';
navigator.serviceWorker.register(sw, {scope: "/"})
.then(function(){
console.log('Service worker registered.');
})
.catch(function(e){
console.log('Service worker not registered ', e);
})
}
In the manifest:
start_url: "/",
scope: "/",
I also tried:
"../", "https://www.localhost.com/", "./",
I am running chrome with the flags:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https://www.localhost.com
But, I also tried to run the application in a remote server with https and I got the same error.
Any help would be nice.
“Does not register a service worker that controls page and start_url. The service worker is the technology that enables your app to use many Progressive Web App features, such as offline, add to homescreen, and push notifications.”
Lighthouse is an open-source, automated tool for improving the quality of web pages. You can run it against any web page, public or requiring authentication. It has audits for performance, accessibility, progressive web apps, and more.
If I uncheck the clear cache option in lighthouse options it starts working.
Edit: As mentioned by Sean McCarthy below the correct name is "Clear storage"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With