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.
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"