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

[workbox-window] New messageSkipWaiting() method #2394

Closed
jeffposnick opened this issue Mar 4, 2020 · 0 comments · Fixed by #2489
Closed

[workbox-window] New messageSkipWaiting() method #2394

jeffposnick opened this issue Mar 4, 2020 · 0 comments · Fixed by #2489
Labels
Feature Request Good First Issue This would be an ideal issue for a new contributor to take on. workbox-window
Milestone

Comments

@jeffposnick
Copy link
Contributor

jeffposnick commented Mar 4, 2020

There's a subtle way that the "Offer a page reload for users" recipe can go wrong, in that the

wb.messageSW({type: 'SKIP_WAITING'});

could, under some circumstances, end up sending that message to the already-active service worker, not the service worker that's currently in the waiting state.

After discussing with @philipwalton, we're going to keep the messageSW() behavior the same (it will always call postMessage() on the service worker instance associated with the Workbox object), and instead come up with a new method—my proposed name is messageSkipWaiting()—that will be equivalent to using messageSW(sw, {type: 'SKIP_WAITING'}) with the sw parameter set to whatever the currently waiting service worker is.

We can then update the recipe to read

wb.messageSkipWaiting();

and it should behave as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Good First Issue This would be an ideal issue for a new contributor to take on. workbox-window
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants