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

serviceworker.skipWaiting #1016

Open
jakearchibald opened this issue Nov 29, 2016 · 3 comments
Open

serviceworker.skipWaiting #1016

jakearchibald opened this issue Nov 29, 2016 · 3 comments

Comments

@jakearchibald
Copy link
Contributor

jakearchibald commented Nov 29, 2016

Allowing:

const reg = await navigator.serviceWorker.ready;
if (reg.waiting) {
  await reg.waiting.skipWaiting();
  location.reload();
}

Usecase: The new service worker has installed, I've shown a message to the user like "New version found. Update now?", which they have clicked.

Currently developers have to postMessage to the service worker for this behaviour.

It's also an opportunity for us to rethink when skipWaiting should resolve in this case. It could resolve once the service worker has begun activating.

@jakearchibald
Copy link
Contributor Author

F2F: lukewarm reception. If it's trivial, we can do it. "If it can live on the main window, it should".

@asakusuma
Copy link

asakusuma commented Mar 23, 2018

Taking it one step further, it would be nice to be able to, from the active worker, call update() in a way that ensures the resulting installation will skipWaiting(). For instance:

registration.update({ skipWaiting: true });

Use case: a worker decides it's not in a good state and wants to force upgrade to the latest.

EDIT: I think the proposal of serviceworker.skipWaiting() is great on its own too.

@dfabulich
Copy link

According to #1303 (comment) linkedin wants this.

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

3 participants