Re: [w3c/ServiceWorker] Provide a way to skipWaiting when the last tab refreshes (#1238)

I don't think the code is buggy. Try this sample. https://github.com/dfabulich/service-worker-refresh-sample

I think you've fallen into a common service worker trap. If you reload on `controllerchange` events and you've opened Chrome Dev Tools and checked the "Update on reload" box on the Application tab, it starts an infinite refresh loop.

Don't do this in the page:

```js
navigator.serviceWorker.addEventListener(`controllerchange`, function (event) {
  window.location.reload();
}
```

do this instead

```js
var refreshing;
navigator.serviceWorker.addEventListener(`controllerchange`, function (event) {
  if (refreshing) return;
  refreshing = true;
  window.location.reload();
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1238#issuecomment-518793545

Received on Tuesday, 6 August 2019 18:41:16 UTC