Skip to content

Sw bugs - #19764

Closed
alxhub wants to merge 2 commits into
angular:masterfrom
alxhub:sw-bugs
Closed

Sw bugs#19764
alxhub wants to merge 2 commits into
angular:masterfrom
alxhub:sw-bugs

Conversation

@alxhub

@alxhub alxhub commented Oct 17, 2017

Copy link
Copy Markdown
Member

No description provided.

@mary-poppins

Copy link
Copy Markdown

You can preview db46964 at https://pr19764-db46964.ngbuilds.io/.

@mary-poppins

Copy link
Copy Markdown

You can preview 18fc7a1 at https://pr19764-18fc7a1.ngbuilds.io/.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you no longer clone here, so the comment is above is out of date since cloning happens within the call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change has no tests. how do we know that it works and that we won't break it in the future?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is covered by the existing tests.

The test mocks previously different from the real browser behavior by 1) not exhausting the body on cache.put() and 2) not throwing an error when an exhausted Response body was reused. As part of this same commit, the mocks were updated to have the correct behavior in both cases. This caused the existing tests to fail without the .clone() operation here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add this info into the commit message and document this kind of stuff in the future? Otherwise these micro changes are hard to review and understand in the future. thanks!

@mary-poppins

Copy link
Copy Markdown

You can preview a998338 at https://pr19764-a998338.ngbuilds.io/.

@IgorMinar IgorMinar added area: service-worker Issues related to the @angular/service-worker package action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: major This PR is targeted for the next major release labels Oct 18, 2017
When Cache.put() is called with a Response, it consumes the response. If
the Response is used for any other purpose (such as satisfying the
original FetchEvent) it must be cloned first.

A bug exists in the mocks used for SW tests, where this condition is not
validated. The bodies of MockResponses can be utilized repeatedly without
erroring in the same way that a real browser would. This bug is fixed by
this commit, which causes tests for the freshness strategy of data caching
to start failing.

The cause of this failure is a second bug in the data caching code, where
the Response is not cloned prior to being passed to Cache.put(). This is
also fixed.
PushEvent.data is not the data object itself, but an instance representing
the data in wire format, with methods to synchronously decode it to JSON,
ArrayBuffer, etc. NGSW assumes all push data is in JSON format.
@alxhub alxhub 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 18, 2017
@mary-poppins

Copy link
Copy Markdown

You can preview dcf50d3 at https://pr19764-dcf50d3.ngbuilds.io/.

tbosch pushed a commit that referenced this pull request Oct 18, 2017
PushEvent.data is not the data object itself, but an instance representing
the data in wire format, with methods to synchronously decode it to JSON,
ArrayBuffer, etc. NGSW assumes all push data is in JSON format.

PR Close #19764
@tbosch tbosch closed this in 396c241 Oct 18, 2017
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 12, 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.

4 participants