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): ensure initialization before handling messages #32525

Closed

Conversation

Splaktar
Copy link
Member

@Splaktar Splaktar commented Sep 7, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Service workers can fail after updates with the exception: Invariant violated (initialize): latest hash null has no known manifest.

Issue Number:
Fixes #25611

What is the new behavior?

  • community members with this issue have tested this fix
    • @hsta verified that users have not seen the issue with this fix
      through all of August

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Fix suggested by @gkalpak. Similar code can be found in Driver.handleFetch().

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 taking this on, @Splaktar ❤️
I have left a couple of suggestions. We should also have some tests for this new behavior.

packages/service-worker/worker/src/driver.ts Show resolved Hide resolved
packages/service-worker/worker/src/driver.ts Outdated Show resolved Hide resolved
@matsko matsko added the area: service-worker Issues related to the @angular/service-worker package label Sep 10, 2019
@ngbot ngbot bot added this to the needsTriage milestone Sep 10, 2019
@paustint
Copy link

@Splaktar #nudge :)

@rebendajirijr
Copy link

Will this be available in next release 9.0.0?

@gkalpak
Copy link
Member

gkalpak commented Oct 10, 2019

@rebendajirijr: Only if the PR is merged in time for the release 😉
@Splaktar: Are you still interested (and available) to move this forward?

@Splaktar
Copy link
Member Author

@gkalpak yeah, I've just been busy with Ivy-related testing/fixes. I will try to get back to this soon. Feel free to take over if you have time to address it now.

@Splaktar Splaktar force-pushed the service-worker-invariant-violated branch 4 times, most recently from 5c3a405 to 0132797 Compare October 26, 2019 01:22
@Splaktar
Copy link
Member Author

I've added a test for handleFetch() where I could reproduce the issue in a test.

I haven't been able to reproduce the handleMessage() exception in a unit test. @gkalpak do you have any ideas there?

@gkalpak
Copy link
Member

gkalpak commented Oct 29, 2019

I have made some changes (including a test for onMessage() and rebasing on master) on my branch gkalpak:service-worker-invariant-violated, but for some reason I could not force-push to your branch 🤷‍♂

Could you port the changes over to your branch to update the PR, @Splaktar? 🙏

@Splaktar
Copy link
Member Author

Splaktar commented Oct 29, 2019

@gkalpak will do! I do have it set to allow edits from maintainers. So I'm not sure what the issue is, but I'll update ASAP, many thanks!

@Splaktar Splaktar force-pushed the service-worker-invariant-violated branch from 0132797 to e653231 Compare October 29, 2019 21:12
@Splaktar
Copy link
Member Author

@gkalpak OK, changes applied. Fixed a typo or two. PTAL.

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 🎉
Can you please update the commit message to not mention fetch (because this commit does not really affect how fetch is handled - initialization did already happen before fetch).

@gkalpak gkalpak added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: patch This PR is targeted for the next patch release type: bug/fix labels Oct 30, 2019
- resolves "Invariant violated (initialize): latest hash null has no known manifest"
- Thanks to @gkalpak and @hsta for helping test and investigate this fix

Fixes angular#25611
@Splaktar Splaktar force-pushed the service-worker-invariant-violated branch from e653231 to afba739 Compare October 30, 2019 23:22
@Splaktar Splaktar changed the title fix(service-worker): ensure initialization in handleMessage() fix(service-worker): ensure initialization before handling messages Oct 30, 2019
@Splaktar
Copy link
Member Author

@gkalpak done.

@gkalpak gkalpak added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Oct 31, 2019
atscott pushed a commit that referenced this pull request Oct 31, 2019
…32525)

- resolves "Invariant violated (initialize): latest hash null has no known manifest"
- Thanks to @gkalpak and @hsta for helping test and investigate this fix

Fixes #25611

PR Close #32525
@atscott atscott closed this in 72eba77 Oct 31, 2019
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…ngular#32525)

- resolves "Invariant violated (initialize): latest hash null has no known manifest"
- Thanks to @gkalpak and @hsta for helping test and investigate this fix

Fixes angular#25611

PR Close angular#32525
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…ngular#32525)

- resolves "Invariant violated (initialize): latest hash null has no known manifest"
- Thanks to @gkalpak and @hsta for helping test and investigate this fix

Fixes angular#25611

PR Close angular#32525
gkalpak pushed a commit to gkalpak/angular that referenced this pull request Nov 11, 2019
…ngular#32525)

- resolves "Invariant violated (initialize): latest hash null has no known manifest"
- Thanks to @gkalpak and @hsta for helping test and investigate this fix

Fixes angular#25611

PR Close angular#32525
kara pushed a commit that referenced this pull request Nov 11, 2019
…32525)

- resolves "Invariant violated (initialize): latest hash null has no known manifest"
- Thanks to @gkalpak and @hsta for helping test and investigate this fix

Fixes #25611

PR Close #32525
@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 Dec 1, 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: 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.

Service worker Invariant violated (initialize): latest hash null
6 participants