GoogleChromeLabs / sw-precache

[Deprecated] A node module to generate service worker code that will precache specific resources so they work offline.
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
5.22k stars 388 forks source link

Generated service worker doesn't claimClient or skipWaiting on Chrome 71 incognito #380

Open kennsippell opened 5 years ago

kennsippell commented 5 years ago

I am generating a service worker script with the following config:

  const config = {
    cacheId: 'cache',
    claimsClient: true,
    skipWaiting: true,
    directoryIndex: false,
    handleFetch: true,
    staticFileGlobs: [
      path.join(staticDirectoryPath, 'manfiest.json'),
    ],
    dynamicUrlToDependencies: {
      [rootUrl]: [path.join(staticDirectoryPath, 'templates', 'inbox.html')],
    },
    stripPrefixMulti: { [staticDirectoryPath]: '' },
    maximumFileSizeToCacheInBytes: 1048576 * 20,
    verbose: true,
  };

  return swPrecache.write(outputPath, config);

The claimsClient: true and skipWaiting: true were working fine for me until I upgrade to Chrome 71. Now when I open a Chrome 71 incogneto window and navigate to the page which registers the service worker, I see the service worker in an "installing..." state. I would expect it to be Installed since it should claim the browser and skip any waiting.

I suspect this isn't an sw-precache issue, but I'm reaching out to better understand the roots for this issue and any workarounds. This same situation is happening for headless Chrome during automated testing.

screenshot from 2019-01-22 18-03-47