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

Prevent refresh on server update #147

Open
Redsandro opened this issue Mar 16, 2019 · 2 comments
Open

Prevent refresh on server update #147

Redsandro opened this issue Mar 16, 2019 · 2 comments

Comments

@Redsandro
Copy link

Redsandro commented Mar 16, 2019

I've installed the ember-service-worker and co plugins basically to allow PWA capabilities, but I'm not actually running custom code yet.

However, with the website installed as PWA, every time there is an update to the Ember app on the server, the page refreshes for everyone who has the PWA open. EVERYONE.

https://youtu.be/74BzSTQCl_c?t=10

How do I prevent this? Where do I listen to the install event and prevent anything from refreshing? Or show a dialog asking the user to refresh now or later?

The refresh is probably caused by this (not sure):

self.addEventListener('install', function installEventListenerCallback(event) {
return self.skipWaiting();
});

I think the skipWaiting() defaults are undocumented.

@ghost
Copy link

ghost commented Apr 4, 2019

I cannot reproduce this, do you have a reproduction for this. The skipWaiting definitely won't cause a browser refresh. There must be other forces at work. Can you help us to some steps to reproduce this behaviour?

@Redsandro
Copy link
Author

Redsandro commented Apr 17, 2019

This happened when the app was at a bare minimum. It doesn't happen anymore. I've been stripping away elements to try to recreate the issue but it doesn't happen again.

It happened with 3 Android phones, when we all tested the PWA from a live server for the first time. When on a page that auto-plays radio - e.g. https://amp.lol/GqO_E1JaK - and stop was clicked, publising a new version to the server caused all phones - even with two minutes delay the one that had the screen off - to start playing music again. In other words, the page was refreshed.

The problem in debugging the cause of this is that I don't know precisely what the lifecycles of service workers and PWAs are. Usually with a better understanding, I am better capable of finding the culprit.

We tested installing and running the PWA in production mode shortly after deploying a version with the following modules installed:

  • ember-service-worker 0.7.2
  • ember-service-worker-asset-cache 0.6.4
  • ember-service-worker-cache-fallback 0.6.2
  • ember-web-app 3.0.0-beta.2
  • fastboot-app-server 1.1.2-beta.1

How does the service worker update when a new version exists anyway? Does it poll?
I guess one difference that I had not yet taken into account is that the PWA had just been freshly installed that day. In subsequent tests, the PWA was (automatically) updated.

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

No branches or pull requests

1 participant