Lighthouse incorrectly states I have not registered a Service Worker

1.3k views Asked by At

The source for my Web App can be found here: - https://drive.google.com/open?id=0B7Rmd3Rn8_hDNW1zSWRoXzBTclU

See line 11 in RegisterServiceWorker.js where I clearly register a ServiceWorker but Lighthouse is currently reporting: -

Does not register a Service Worker and User will not be prompted to Install the Web App Failures: Manifest does not have icons at least 192px, Site does not register a Service Worker, Manifest start_url is not cached by a Service Worker.

Why is it not seeing the Service Worker that I registered?

2

There are 2 answers

2
oninross On

If I am not mistaken, there are no icon assets in the folder. Yes you have gingerbreadhouse.png in the folder but its not the dimensions that its specifically needed for the manifest file. See this for details on how to declare the icons.

{
    "short_name": "AirHorner",
    "name": "Kinlan's AirHorner of Infamy",
    "icons": [
        {
            "src": "launcher-icon-1x.png",
            "type": "image/png",
            "sizes": "48x48"
        },
        {
            "src": "launcher-icon-2x.png",
            "type": "image/png",
            "sizes": "96x96"
        },
        {
            "src": "launcher-icon-4x.png",
            "type": "image/png",
            "sizes": "192x192"
        }
    ],
    "start_url": "index.html?launcher=true"
}
0
KlavierCat On

not enough reputation to add comment. But, if you happen to register the service worker near the end of page load, in a lazy-loading fashion, try moving the service worker registration part to the head tag and you might get a pass. Not saying that this is a good way of doing things, but there is an issue with Lighthouse: https://github.com/GoogleChrome/lighthouse/issues/1815

I run into this, having a fully working service worker but Lighthouse is telling me otherwise, and I was able to get a pass by moving the service worker registration part to the head tag.