lighthouse: Service worker does not successfully serve the manifest's start_url.

This error is actually pretty hard to fix if you think you are.

At the moment I’m caching the index.html page and I’ve set the start_url to index.html and I still get this error.

I can even go from DevTools > Application > Manifest > start_url link to the page, switch to offline in network panel and reload the page and get the full page from the service worker.

Any ideas how to debug this?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 17
  • Comments: 48

Most upvoted comments

@frlinw we totally agree! on latest LH I don’t see any of those issues on your site though so hopefully fixed in the past couple months 👍

image

@wdiechmann there is such an option in devtools -> application tab. This option is handy while developing and ignoring the Service Worker but it has nothing to do with Lighthouse itself. image

@Drag13 I get a 404 on http://makephoto.azurewebsites.net/manifest.json or https://makephoto.azurewebsites.net/manifest.json

you can see if the manifest gets loaded correctly in the application tab image

we’re rolling the latest lighthouse to canary as we speak, look out for it next week 😃

The piece of code that @icyJoseph pinpointed is where the display string is being added to the set of errors but not the cause of the bug.

@brendankenny didn’t you recently discover something w.r.t manifest parsing that might help here?

Yeah I’ve pretty much given up on fixing this error: Service worker does not successfully serve the manifest’s start_url.

When you view my site www.mlamannadev.com from an android device a banner does pop up so I don’t know why I’m still getting this error in lighthouse.

I could of course be wrong, but yes. There seems to be a false negative. Please refer to:

The blame seems to come from: https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/audits/webapp-install-banner.js

In line 78,

static assessOfflineStartUrl(artifacts, result) {
    const hasOfflineStartUrl = artifacts.StartUrl.statusCode === 200;

    if (!hasOfflineStartUrl) {
      result.failures.push('Service worker does not successfully serve the manifest\'s start_url');
      if (artifacts.StartUrl.debugString) result.failures.push(artifacts.StartUrl.debugString);
    }

    if (artifacts.StartUrl.debugString) {
      result.warnings.push(artifacts.StartUrl.debugString);
    }
  }

Hopefully this gives you more insight on to how to fix your problem. For me this is as far as I go to jump over a false negative.

Hi,

I have encountered the same issue, when using create-react-app, out of the box because the service worker fails to serve the start_url, as you can see in this image:

start_url fail

In order to fix this, I’ve fetched a service worker script from: http://www.manifoldjs.com/ using the Service Worker for offline pages.

self.addEventListener("fetch", function(event) {
  event.respondWith(
    fetch(event.request).catch(function(error) {
      console.log(
        "[Service Worker] Network request Failed. Serving content from cache: " +
          error
      );
      //Check to see if you have it in the cache
      //Return response
      //If not in the cache, then return error page
      return caches
        .open(
          "sw-precache-v3-sw-precache-webpack-plugin-https://silent-things.surge.sh"
        )
        .then(function(cache) {
          return cache.match(event.request).then(function(matching) {
            var report =
              !matching || matching.status == 404
                ? Promise.reject("no-match")
                : matching;
            return report;
          });
        });
    })
  );
});

Then I use cra-append-sw to append this code to the Create-React-App default Service Worker. Set start_url in manifest to “./index.html” and it passes the audit. Note that the index.html is server anyway, so this might just be a Lighthouse bug.

Hope this hopes with the investigation. I have made a repo with the code that should work here: https://github.com/icyJoseph/test-worker/blob/master/src/service-worker.js

It depends on the Lighthouse version and not at the Chrome version. Just a short overview from myself with my website:

  • Integrated Lighthouse 2.9.1 from Chrome 67.0.3396.79 (Windows) shows the error
  • Lighthouse extension 3.0.0-beta.0 which could be installed at Chrome 67.0.3396.79 fixes the error
  • Integrated Lighthouse 3.0.0-beta.0 from Chrome Canary 69.0.3457.0 (Windows) fixes the error

An interessting point is that the Lighthouse extension is tagged as version 2.10.1.3000 and the Lighthouse itself shows version 3.0.0-beta.0.

@wdiechmann which Lighthouse version do you have at your mac Chrome Canary? I’m on windows here at work and can’t check the mac version. Your PDF report was build with version 2.9.4. You may could try to install the extension?

I’m still having this issue in Chrome 67.0.3396.79. (it seems to be the same issue, as my app passes the Lighthouse audit in Chrome Canary 69.0.3455.0). Is there any workaround?

index.html is cached by Workbox and there is start_url: / in the web app manifest image About error message:

  • Service worker does not successfully serve the manifest's start_url: Acceptable. index.html is not equal to / but in fact, the install banner appears and after installation, the PWA works as expected, so the browser understands that index.html === /, why the audit can’t ?
  • No usable web app manifest found on page ... : Misleading. There is a web app manifest (visible in Application tab > Manifest)
  • No start URL to fetch : Misleading. There is a start URL

Not entirely 😛

the bug was fixed when #4710 landed as there was a race condition when the manifest wasn’t cached on time. After that one it was just a wording error in the audit.

going to try a fresh CRA, thanks for the feedback

The service worker issue got resolved here #4070

it more or less comes to this bug #4898 i’ll try to figure something out somewhere this week.

I might be completely wrong here.

@icyJoseph seems to have pinpointed the piece of code responsible for this pretty serious bug https://github.com/GoogleChrome/lighthouse/issues/4541#issuecomment-367006053

@patrickhulce @wardpeet @paulirish @karolklp Could one of you review and confirm if he’s correct (that it’s a false positive) and suggest or implement a fix?

It’s causing fresh create-react-app projects to fail—as well as fresh Google projects.

@Stefany93 same thing here… I assume that Google Lighthouse is not their top priority looking at the speed of development and improvement :shipit:

Same here. The banner does pop up on android device but the stupid error makes my Lighthouse has 82 points.

The project is the wsk-next branch of web-starter-kit https://github.com/google/web-starter-kit/tree/wsk-next

in the directory run:

  1. npm install
  2. gulp prod