Go to file
Alex Rickabaugh 395109817b fix(service-worker): properly handle invalid hashes in all scenarios (#21288)
When the SW fetches URLs listed in a manifest with hashes, it checks
the content hash against the manifest to make sure it has the correct
version of the URL. In the event of a mismatch, the SW is supposed to
consider the manifest invalid, and avoid using it. There are 3 cases
to consider by which this can happen.

Case 1: during the initial SW installation, a manifest is activated
without waiting for every URL to be fully loaded. In the background,
every prefetch URL listed by the manifest is requested and cached.
One such prefetch request could fail the hash test, and cause the
manifest to be treated as invalid. In such a case, the SW should
enter a state of EXISTING_CLIENTS_ONLY, as the latest manifest is
invalid.

This case works today.

Case 2: during the initial SW installation, as in Case 1, a manifest
is activated without waiting for each URL to fully load. However,
it's possible that the application could request a URL with a bad
hash before background initialization tries to load that URL. This
happens if, for example, the application has a broken index.html.

In this case, the SW should enter a state of EXISTING_CLIENTS_ONLY,
and serve the request from the network instead.

What happens today is that the internal error escapes the SW and
is returned as a rejected Promise to respondWith(), causing a
browser-level error that the site cannot be loaded, breaking the
site.

This change allows the SW to detect the error and enter the correct
state, falling back on the network if needed.

Case 3: during checkForUpdate(), the SW will try to fully cache the
new update before making it the latest version. Failure here is
complicated - if the page fails to load due to transient network
conditions (timeouts, 500s, etc), then it makes sense to continue
serving the existing cached version, and attempt to activate the
update on the next cycle.

If the page fails due to non-transient conditions though (400 error,
hash mismatch, etc), then the SW should consider the updated
manifest invalid, and enter a state of EXISTING_CLIENTS_ONLY.

Currently, all errors are treated as transient.

This change causes the SW to treat all errors during updates as
non-transient, which can cause the SW to unnecessarily enter a
safe mode. A future change can allow the SW to remain in normal mode
if the error is provably transient.

PR Close #21288
2018-01-10 12:18:24 -08:00
.circleci build: add bazel rulse for benchmarks (#21436) 2018-01-10 11:58:53 -08:00
.github docs: does please -> does (#18044) 2017-07-11 11:46:57 -07:00
aio build(aio): upgrade to zone.js@0.8.19 (#21349) 2018-01-09 10:33:50 -08:00
docs build: force upstream fetch before merge (#21192) 2017-12-27 17:42:03 -06:00
integration build(core): reduce payload limit back to normal (#21394) 2018-01-08 12:02:30 -08:00
modules build: add bazel rulse for benchmarks (#21436) 2018-01-10 11:58:53 -08:00
packages fix(service-worker): properly handle invalid hashes in all scenarios (#21288) 2018-01-10 12:18:24 -08:00
scripts build: upgrade Bazel to 0.9.0 (#21335) 2018-01-09 10:28:46 -08:00
tools fix(common): export currencies via `getCurrencySymbol` (#20983) 2018-01-05 14:24:26 -08:00
.bowerrc chore(dgeni): clean up legacy typings bundle creation 2015-10-29 21:19:59 +00:00
.clang-format feat(tooling): Add a .clang-format for automated JavaScript formatting. 2015-04-02 08:44:34 -07:00
.editorconfig chore(.editorconfig): include markdown config 2015-01-27 00:14:48 -08:00
.gitattributes chore: force lf EOL for ts files (#11143) 2016-08-29 12:41:58 -07:00
.gitignore build(common): extract i18n locale data from cldr (#18284) 2017-08-22 15:43:04 -05:00
.mailmap build: add a Git .mailmap with my new name (#19550) 2017-10-09 14:35:30 -07:00
.nvmrc build: update node version number in .nvmrc (#20832) 2017-12-12 11:56:18 -08:00
.pullapprove.yml ci: update forms approval list to include guides (#21449) 2018-01-10 12:15:50 -08:00
.travis.yml ci: temporary work-around for Travis issue (#21422) 2018-01-09 12:25:18 -08:00
BUILD.bazel build: move _testing_init into tools; limit web_test concurrency (#21053) 2017-12-22 13:10:51 -08:00
CHANGELOG.md docs(core): provide note for unit test changes with the `ng-star-inserted` className (#21450) 2018-01-10 11:13:52 -08:00
CONTRIBUTING.md docs(aio): Add instructions to fork angular/angular (#20462) 2017-11-15 18:26:27 -06:00
LICENSE docs(common): update copyright years (#21232) 2018-01-04 17:45:36 -05:00
README.md docs: remove broken issuestats.com badges (#21334) 2018-01-05 14:43:18 -05:00
WORKSPACE build: upgrade Bazel to 0.9.0 (#21335) 2018-01-09 10:28:46 -08:00
bower.json docs: branding fixes (#14132) 2017-01-27 15:03:11 -06:00
browser-providers.conf.js build: remove required BrowserStack run as it fails with “Access denied” (#19769) 2017-10-17 15:51:40 -07:00
build.sh build: make umd.min.js source map paths relative (#21147) 2017-12-21 20:11:20 -08:00
gulpfile.js test(packaging): added test for source map correctness 2017-09-12 16:59:32 -04:00
karma-js.conf.js build: activate render3 tests in CI (#21279) 2018-01-05 14:25:40 -08:00
package.json release: cut the 5.2.0 release 2018-01-09 16:55:58 -08:00
protractor-e2e.conf.js refactor: add license header to JS files & format files (#12081) 2016-10-04 20:39:20 -07:00
protractor-examples-e2e.conf.js refactor: format and lint code 2016-12-12 11:30:25 -08:00
protractor-perf.conf.js refactor: add license header to JS files & format files (#12081) 2016-10-04 20:39:20 -07:00
shims_for_IE.js Revert "refactor: add license header to JS files & format files (#12035)" 2016-10-04 14:06:41 -07:00
test-events.js fix(platform-browser): run BLACK_LISTED_EVENTS outside of ngZone (#18993) 2017-09-05 15:33:22 -05:00
test-main.js build: add bazel test rules for remainder of packages (#21053) 2017-12-22 13:10:51 -08:00
test.sh build: remove references to `tsc-wrapped` (#19298) 2017-09-21 13:55:52 -07:00
tslint.json build: add lint rule for global flags in rollup config (#20028) 2017-10-30 23:09:16 -04:00
yarn.lock build: upgrade to TypeScript 2.6 (#21144) 2017-12-22 20:15:47 -08:00
yarn.lock.readme.md build: switch from npm to yarn (#19328) 2017-09-22 13:20:52 -07:00

README.md

Build Status CircleCI BrowserStack Status Join the chat at https://gitter.im/angular/angular npm version

Sauce Test Status

Safari (7+), iOS (7+) and IE mobile (11) are tested on BrowserStack.

Angular

Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.

Quickstart

Get started in 5 minutes.

Want to help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.