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

feat(service-worker): add helper script which will uninstall SW #21863

Closed
wants to merge 1 commit into from

Conversation

alxhub
Copy link
Member

@alxhub alxhub commented Jan 29, 2018

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.

@mary-poppins
Copy link

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.
@mary-poppins
Copy link

You can preview b228c6a at https://pr21863-b228c6a.ngbuilds.io/.

@alxhub alxhub added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Jan 29, 2018
@jasonaden jasonaden added the area: service-worker Issues related to the @angular/service-worker package label Jan 29, 2018
@alxhub alxhub requested a review from IgorMinar January 29, 2018 18:57
@jasonaden jasonaden added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: merge The PR is ready for merge by the caretaker labels Jan 29, 2018
@alxhub alxhub added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jan 29, 2018
Copy link
Member

@gkalpak gkalpak left a 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(
Copy link
Member

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?

Copy link
Member Author

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.

@jasonaden jasonaden closed this in b10540a Jan 30, 2018
@IgorMinar
Copy link
Contributor

@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

jbogarthyde pushed a commit to jbogarthyde/angular that referenced this pull request Feb 23, 2018
…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
leo6104 pushed a commit to leo6104/angular that referenced this pull request Mar 25, 2018
…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
@YuZaiShui
Copy link

emm, what is the best way to unregister service-worker now with the Service-Worker package? I'd really like to unregister this now.

@gkalpak
Copy link
Member

gkalpak commented May 20, 2019

@YuZaiShui, see the Service Worker in Production guide.

@YuZaiShui
Copy link

@gkalpak thanks very much, It looks like will help me to solve a big problem.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: service-worker Issues related to the @angular/service-worker package cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants