Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service worker does not successfully serve the manifest's start_url. #4541

Closed
gauntface opened this issue Feb 14, 2018 · 48 comments
Closed

Service worker does not successfully serve the manifest's start_url. #4541

gauntface opened this issue Feb 14, 2018 · 48 comments

Comments

@gauntface
Copy link

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?

@patrickhulce
Copy link
Collaborator

Potentially a case of #2688?

@gauntface
Copy link
Author

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

@icyJoseph
Copy link

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

@JustFly1984
Copy link

I'm not using CRA, but I've copied whole code concerning SW to my project based on react-static

Can you please explain the meaning of "sw-precache-v3-sw-precache-webpack-plugin-https://silent-things.surge.sh" string?

Can I copy this code to my register service worker file safely?

@JustFly1984
Copy link

I've navigated to https://silent-things.surge.sh/, used Audit, and get the same Service worker does not successfully serve the manifest's start_url. error

@icyJoseph
Copy link

icyJoseph commented Feb 19, 2018

Hej,

That's the name of the cache, aka cacheName, replace it with yours, that string is the url of project I used to test CRA, combined with some CRA defaults.

EDIT

I have now deployed to https://silent-things.surge.sh

I would just like you to say that without this add-on to the CRA service worker, the app does serve index.html in offline mode, it is just lighthouse that flags it.

@JustFly1984
Copy link

Ok, so as I understand, this peace of code has no real value, except making lighthouse to stop false negative warning?

@icyJoseph
Copy link

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.

@mclamanna
Copy link

mclamanna commented Mar 19, 2018

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.

@JosefJezek
Copy link

I have the same problem. :-( I am using polymer cli and sw-precache.

@Stefany93
Copy link

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

@stefanklokgieters
Copy link

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

@corysimmons
Copy link

corysimmons commented Apr 22, 2018

@icyJoseph seems to have pinpointed the piece of code responsible for this pretty serious bug #4541 (comment)

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

@patrickhulce
Copy link
Collaborator

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?

@corysimmons
Copy link

Thanks for the info @patrickhulce and helping move this along.

@wardpeet
Copy link
Collaborator

wardpeet commented Apr 23, 2018

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.

@wardpeet
Copy link
Collaborator

wardpeet commented Apr 29, 2018

does this work for you people? #5067
Honestly it just gives a better error message. If not could you give me a good test url that's still broken with the #5067 patch.

@corysimmons
Copy link

corysimmons commented Apr 30, 2018

The user is prompted to install the PWA though.

The problem, for me anyway, is I ran Lighthouse with a fresh CRA app, and this error made me think it wouldn't install a PWA. When I opened the url on Android, it did prompt to install...

If Lighthouse is determining XYZ makes something not a PWA, when it is a PWA, then Lighthouse needs to be fixed to not determine that.

@wardpeet
Copy link
Collaborator

going to try a fresh CRA, thanks for the feedback

@wardpeet
Copy link
Collaborator

I tested this one and seems to be good.
wdyt @patrickhulce @patrickhulce @gauntface ?

yarn start (dev mode) - no Service Worker
image

yarn build (prod mode) - with Service Worker
image

@patrickhulce
Copy link
Collaborator

@wardpeet out of curiosity wanna test real quick with/without 30eb6ce? I'm wondering if that fixed things by chance

@wardpeet
Copy link
Collaborator

@patrickhulce it's the same result with just fetch. The fix was actually the one #5067 as the messages were just messed up as the service worker is not registered on yarn start

you can test it here https://build-zzbfraodkg.now.sh/

@patrickhulce
Copy link
Collaborator

Oooooooh, gotcha so it was always working with CRA then?

@wardpeet
Copy link
Collaborator

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.

@madmoizo
Copy link

madmoizo commented May 18, 2018

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

@patrickhulce
Copy link
Collaborator

patrickhulce commented May 18, 2018

@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

@madmoizo
Copy link

@patrickhulce thanks ! I ran the audit on canary (v68) because I tought it was the latest lighthouse version but with the chrome extension it's all good.

@patrickhulce
Copy link
Collaborator

we're rolling the latest lighthouse to canary as we speak, look out for it next week :)

@mrtnmgs
Copy link

mrtnmgs commented Jun 12, 2018

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?

@wdiechmann
Copy link

wdiechmann commented Jun 12, 2018

hmmm - I get the Service worker does not successfully serve... when auditing, but from the Application tab, with Manifest selected, I am able to Add to Homescreen then select Service Workers and go Offline, then select Manifest and click the start_url and see the browser window flicker just noticeable (which I guess will equal a '200')

This happens in Chrome (Version 66.0.3359.181 (Officiel version) (64-bit)) and Chrome Canary (Version 69.0.3455.0 (Officiel version) canary (64-bit)) on macOS

I added the outputs of lighthouse https://app.localhost --verbose 2>log&
log.txt
Lighthouse_Report.pdf

@fry2k
Copy link

fry2k commented Jun 13, 2018

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?

@Drag13
Copy link

Drag13 commented Jun 19, 2018

Chrome: Version 67.0.3396.87 (Official Build) (64-bit)
Create-react-app: Version 1.5.2
Integrated Lighthouse: Version 2.9.1

Manifest is present but I got the same error:

image

@patrickhulce
Copy link
Collaborator

@Drag13 does using latest LH (3.0.0-beta.0) fix your issue?

@Drag13
Copy link

Drag13 commented Jun 19, 2018

@patrickhulce I am sorry, but could you point me where I can get beta-version. On the market, I see only 2.10.1.3000

@patrickhulce
Copy link
Collaborator

@Drag13 that you should be using 3.0.0-beta under the hood :)

@wardpeet
Copy link
Collaborator

@Drag13 @wdiechmann @mrtnmgs
Chrome 67 (current stable) does not have the latest lighthouse which not holds the fix for this audit.
Chrome 69 (current canary) does has the fix and latest lighthouse. Could you try that one.

You could also try the chrome extension from the chrome store.

it's actually just a @fry2k said :)

@Drag13
Copy link

Drag13 commented Jun 20, 2018

Chrome: Version 69.0.3466.0 (Official Build) canary (64-bit)
Failures: No manifest was fetched.

image

Same for the latest official Chrome and LH latest extension.
Do you need link to the app?

@fry2k
Copy link

fry2k commented Jun 21, 2018

@Drag13
Yes a link to your app would help me.
In my opinion it seems to be really a problem with fetching the manifest because the brand color is also missing. Or didn't you define the brand color at your manifest?

@wdiechmann
Copy link

would a somewhat clearer error-message aid all of us "earthlings" to squelching your 'in-tray' ?

like:

parsing manifest.json failed: brand color missing

Another thing:
When I see a 404 and Lighthouse tells me that a manifest was not fetched, and a manifest.json is in fact present at the correct place - where would I start looking?

Reflexion:
The entire PWA thing seems (to me) to collide with other client strategies, like caching for one. While developing it would be very welcomed to somehow flip-a-switch and suddenly Chrome would load fresh copies of all assets on every reload. No emptying of caches, deleting content, and what-not - just my 2cent

@Drag13
Copy link

Drag13 commented Jun 21, 2018

App was here
Manifest is here

{
  "short_name": "Upload",
  "name": "UploadPage",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    }
  ],
  "start_url": "./index.html",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

Could this be connected with no force redirect from http to https?

@wardpeet
Copy link
Collaborator

wardpeet commented Jun 21, 2018

@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

@Drag13
Copy link

Drag13 commented Jun 21, 2018

Manifest is definitely there

image

Seems problem is in hosting permissions. I will check later and return. Thanks for the help!

@wdiechmann
Copy link

@wardpeet great! I was of the impression that checkbox would only reload the serviceworker

@Drag13
Copy link

Drag13 commented Jun 21, 2018

Problem was on the my side.
Azure doesn't serve static json files without proper web.config.

Chrome 67.0.3396.87 - All works fine
Chrome 69.0.3466.0 - All works fine

@wardpeet Thanks a lot for the help!

@patrickhulce
Copy link
Collaborator

@wdiechmann the magic checkbox that makes this mode work is actually "Bypass for network", between that and "Disable cache" in the network tab you should be getting fresh assets from server every time :)

@wardpeet
Copy link
Collaborator

@patrickhulce yeah correct sorry! :)

@wdiechmann
Copy link

@patrickhulce @wardpeet affirmative :)

thx!

@wardpeet
Copy link
Collaborator

wardpeet commented Jul 28, 2018

I'm closing this issue, I'm pretty sure this one got fixed. if not please create a new ticket with new information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

17 participants