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

fix(service-worker): clear service worker cache in safety worker #43324

Closed
wants to merge 1 commit into from
Closed

fix(service-worker): clear service worker cache in safety worker #43324

wants to merge 1 commit into from

Conversation

naveedahmed1
Copy link
Contributor

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes #43163

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • [ x] Bugfix
  • [ x] Improvements in safety worker

What is the current behavior?

Currently, safety worker only unregisters old service worker, while leaving the service worker cache. This creates problem when cache contains broken contents and sometimes causes new service worker to serve the contents from the old cache. Hence failing the purpose of safety worker.

Issue Number: 43163

What is the new behavior?

After unregistering old service worker, clear cache of angular service worker. This ensure that the new service worker doesn't serve stale or broken contents.

Does this PR introduce a breaking change?

  • Yes
  • [x ] No

@google-cla google-cla bot added the cla: yes label Sep 2, 2021
@pullapprove pullapprove bot requested a review from IgorMinar September 2, 2021 17:44
@atscott atscott added the area: service-worker Issues related to the @angular/service-worker package label Sep 2, 2021
@ngbot ngbot bot added this to the Backlog milestone Sep 2, 2021
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.

Thx, @naveedahmed1 👍

I've left a couple of suggestions. Could you also mention the change in the Safety Worker section of Service worker in production guide? 🙏

packages/service-worker/safety-worker.js Outdated Show resolved Hide resolved
@naveedahmed1
Copy link
Contributor Author

Thanks @gkalpak I have incorporated the changes you suggested. I hope everything is in order now :D

packages/service-worker/safety-worker.js Outdated Show resolved Hide resolved
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.

Thx for making the changes, @naveedahmed1 👍
I have left a couple of small suggestions regarding the docs. Can you also please ensure that there is only a single commit on the PR (since this is conceptually a single change) 🙏

aio/content/guide/service-worker-devops.md Outdated Show resolved Hide resolved
aio/content/guide/service-worker-devops.md Outdated Show resolved Hide resolved
@pullapprove pullapprove bot requested a review from atscott September 13, 2021 15:02
@google-cla
Copy link

google-cla bot commented Sep 13, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Sep 13, 2021
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.

Thx, @naveedahmed1 👍

It looks good to me, except I still see 5 commits on the PR: https://github.com/angular/angular/pull/43324/commits
Can you please make sure there is only a single commit?

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes #43163
@google-cla google-cla bot added cla: yes and removed cla: no labels Sep 13, 2021
@gkalpak gkalpak added target: patch This PR is targeted for the next patch release type: bug/fix labels Sep 13, 2021
@gkalpak gkalpak added the action: merge The PR is ready for merge by the caretaker label Sep 13, 2021
AndrewKushnir pushed a commit that referenced this pull request Sep 13, 2021
)

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes #43163

PR Close #43324
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Sep 16, 2021
…ular#43324)

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes angular#43163

PR Close angular#43324
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Sep 22, 2021
…ular#43324)

clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes angular#43163

PR Close angular#43324
@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 Oct 14, 2021
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: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There should be a seamless way to get rid of broken service worker state
3 participants