Go to file
Adrien Vergé d63ecf4c5f fix(service-worker): Don't stay locked in EXISTING_CLIENTS_ONLY if corrupted data (#37453)
**Problem**

After #31109 and #31865, it's still possible to get locked in state
`EXISTING_CLIENTS_ONLY`, without any possibility to get out (even by
pushing new updates on the server).
More specifically, if control doc `/latest` of `ngsw:/:db:control` once
gets a bad value, then the service worker will fail early, and won't be
able to overwrite `/latest` with new, valid values (the ones from future
updates).

For example, once in this state, URL `/ngsw/state` will show:

    NGSW Debug Info:
    Driver state: EXISTING_CLIENTS_ONLY (Degraded due to failed initialization: Invariant violated (initialize): latest hash 8b75… has no known manifest
    Error: Invariant violated (initialize): latest hash 8b75… has no known manifest
        at Driver.<anonymous> (https://my.app/ngsw-worker.js:2302:27)
        at Generator.next (<anonymous>)
        at fulfilled (https://my.app/ngsw-worker.js:175:62))
    Latest manifest hash: 8b75…
    Last update check: 22s971u

... with hash `8b75…` corresponding to no installed version.

**Solution**

Currently, when such a case happens, the service worker [simply fails
with an assertion][1]. Because this failure happens early, and is not
handled, the service worker is not able to update `/latest` to new
installed app versions.

I propose to detect this corrupted case (a `latest` hash that doesn't
match any installed version) a few lines above, so that the service
worker can correctly call its [already existing cleaning code][2].

[1]: https://github.com/angular/angular/blob/3569fdf/packages/service-worker/worker/src/driver.ts#L559-L563
[2]: https://github.com/angular/angular/blob/3569fdf/packages/service-worker/worker/src/driver.ts#L505-L519

This change successfully fixes the problem described above.

Unit test written with the help of George Kalpakas. Thank you!

PR Close #37453
2020-06-08 09:31:34 -07:00
.circleci docs: fix various typos (#37443) 2020-06-04 16:03:54 -07:00
.devcontainer
.github docs: update the stackblitz in the GitHub Issue template (#37219) 2020-06-03 15:55:44 -07:00
.ng-dev refactor(dev-infra): change required base commit sha (#37424) 2020-06-04 10:44:14 -07:00
.vscode
.yarn
aio build: update to latest stable Chromium 83.0.4103 in both rules_webtesting and puppeteer (#37427) 2020-06-08 09:16:40 -07:00
dev-infra fix(dev-infra): await setup in runBenchmark (#37428) 2020-06-08 09:17:34 -07:00
docs docs: add blank line before header (#37391) 2020-06-04 09:20:26 -07:00
goldens build: fix integration payload sizes 2020-06-02 10:51:06 -07:00
integration build: upgrade to bazel 3.2.0 and rules_nodejs 1.7.0 (#37358) 2020-06-08 09:15:50 -07:00
modules refactor(dev-infra): small changes and fixes (#36800) 2020-06-03 13:12:30 -07:00
packages fix(service-worker): Don't stay locked in EXISTING_CLIENTS_ONLY if corrupted data (#37453) 2020-06-08 09:31:34 -07:00
scripts build: update to latest stable Chromium 83.0.4103 in both rules_webtesting and puppeteer (#37427) 2020-06-08 09:16:40 -07:00
third_party
tools refactor(dev-infra): small changes and fixes (#36800) 2020-06-03 13:12:30 -07:00
.bazelignore
.bazelrc
.bazelversion build: upgrade to bazel 3.2.0 and rules_nodejs 1.7.0 (#37358) 2020-06-08 09:15:50 -07:00
.clang-format
.editorconfig
.gitattributes
.gitignore
.mailmap
.nvmrc
.pullapprove.yml ci: special case tooling-cli-shared-api review group (#37467) 2020-06-05 19:23:52 -07:00
.yarnrc
BUILD.bazel revert: "revert: "feat(dev-infra): exposed new rule 'component_benchmark' via dev_infra (#36434)" (#36798)" (#36800) 2020-06-03 13:12:30 -07:00
CHANGELOG.md docs: release notes for the v10.0.0-rc.2 release 2020-06-01 11:14:39 -07:00
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE
README.md
WORKSPACE build: upgrade to bazel 3.2.0 and rules_nodejs 1.7.0 (#37358) 2020-06-08 09:15:50 -07:00
browser-providers.conf.js ci: temporarily disable Android 10 browser unit tests on Saucelabs (#37399) 2020-06-02 17:32:34 -04:00
gulpfile.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
karma-js.conf.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
package.json build: update to latest stable Chromium 83.0.4103 in both rules_webtesting and puppeteer (#37427) 2020-06-08 09:16:40 -07:00
shims_for_IE.js
test-events.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-main.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
tslint.json
yarn.lock build: update to latest stable Chromium 83.0.4103 in both rules_webtesting and puppeteer (#37427) 2020-06-08 09:16:40 -07:00
yarn.lock.readme.md

README.md

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

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.

Changelog

Learn about the latest improvements.

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.