1

If i navigate from the web app, and no longer have any windows open, when i return back to the app the install event is called every time before activate. This doesn't match the expected lifecycle of install only been called once. I'm not making any changes to the service worker file.

The only code in the service worker is:

self.addEventListener('install', function(event) {
    console.log('[ServiceWorker:install] Installing service worker v6.');
});

self.addEventListener('activate', event => {
    console.log(`[ServiceWorker:activation] Activating service worker v6.`);
});
JMac
  • 523
  • 1
  • 5
  • 17
  • You're right in that isn't the expected behavior. If you're using Chrome, do you potentially have the "Update on reload" option checked? https://developers.google.com/web/tools/chrome-devtools/progressive-web-apps#service-workers – Jeff Posnick Jan 26 '18 at 20:57
  • Can confirm the same behavior. I'm going through https://developers.google.com/web/ilt/pwa/lab-scripting-the-service-worker and get installing/activating messages on step 3.2 after closing and reopening the browser tab – Mikhail Romanov May 17 '18 at 15:09
  • That seemed to be old logs(see my response below) – Mikhail Romanov May 17 '18 at 15:18

1 Answers1

1

That is probably old logs.

You can either clear console or add timestamp to the logs to see that ...installing/...activating messages are logged before you closed/opened the browser window.

Credits to this answer: https://stackoverflow.com/a/41153031/4956536

Mikhail Romanov
  • 1,542
  • 1
  • 13
  • 20