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
feat(service-worker): add helper script which will uninstall SW #21863
Conversation
You can preview 8b6a186 at https://pr21863-8b6a186.ngbuilds.io/. |
Service Workers can be tricky to work with in production, and often it becomes necessary to deactivate an existing SW. This is trickier than one might imagine - as long as clients on the old SW may exist it is important to serve some script at the old SW URL. This commit adds safety-worker.js to the published NPM package, which is useful for that purpose. On install the SW unregisters itself which safely and gradually allows older clients to update.
You can preview b228c6a at https://pr21863-b228c6a.ngbuilds.io/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (except for the missing docs 😁)
|
||
self.addEventListener('activate', event => { | ||
event.waitUntil(self.clients.claim()); | ||
self.registration.unregister().then( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have to be in event.waitUntil()
or wait for the clients.claim()
to complete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not, but you never know with Service Workers.
@gkalpak can you please set the "PR action: cleanup" label next time when you approve a change, but request smaller changes? This PR got merged by accident without docs because all the PR statuses were green. Had you set the "cleanup" label, it would be clear that a minor action is required before the merge can proceed. I also filed #21919 and dropseed/pullapprove-support#117 to help prevent this in the future. Thanks |
…lar#21863) Service Workers can be tricky to work with in production, and often it becomes necessary to deactivate an existing SW. This is trickier than one might imagine - as long as clients on the old SW may exist it is important to serve some script at the old SW URL. This commit adds safety-worker.js to the published NPM package, which is useful for that purpose. On install the SW unregisters itself which safely and gradually allows older clients to update. PR Close angular#21863
…lar#21863) Service Workers can be tricky to work with in production, and often it becomes necessary to deactivate an existing SW. This is trickier than one might imagine - as long as clients on the old SW may exist it is important to serve some script at the old SW URL. This commit adds safety-worker.js to the published NPM package, which is useful for that purpose. On install the SW unregisters itself which safely and gradually allows older clients to update. PR Close angular#21863
emm, what is the best way to unregister service-worker now with the Service-Worker package? I'd really like to unregister this now. |
@YuZaiShui, see the Service Worker in Production guide. |
@gkalpak thanks very much, It looks like will help me to solve a big problem. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Service Workers can be tricky to work with in production, and often
it becomes necessary to deactivate an existing SW. This is trickier
than one might imagine - as long as clients on the old SW may exist
it is important to serve some script at the old SW URL. This commit
adds safety-worker.js to the published NPM package, which is useful
for that purpose. On install the SW unregisters itself which safely
and gradually allows older clients to update.