angular-docs-cn/packages
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
..
animations build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
bazel build: upgrade to bazel 3.2.0 and rules_nodejs 1.7.0 (#37358) 2020-06-08 09:15:50 -07:00
benchpress build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
common fix(common): prevent duplicate URL change notifications (#37404) 2020-06-04 16:45:06 -07:00
compiler build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
compiler-cli ci: special case tooling-cli-shared-api review group (#37467) 2020-06-05 19:23:52 -07:00
core fix(core): infinite loop if injectable using inheritance has a custom decorator (#37022) 2020-06-03 13:16:25 -07:00
docs docs(di): fix typo in advanced di doc (#36634) 2020-05-01 09:50:28 -07:00
elements fix(elements): fire custom element output events during component initialization (#36161) 2020-06-05 10:36:39 -07:00
examples build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
forms refactor(forms): use a type guard to get rid of casts (#32541) 2020-06-03 12:29:26 -07:00
language-service fix(language-service): Recover from error in analyzing Ng Modules (#37108) 2020-06-03 15:56:19 -07:00
localize build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
platform-browser build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
platform-browser-dynamic build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
platform-server build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
platform-webworker build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
platform-webworker-dynamic build: remove wombot proxy registry from package.jsons for release (#37378) 2020-06-01 12:41:19 -04:00
private/testing build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
router docs(router): fix a typo in example code (#37309) 2020-06-01 17:19:45 -04:00
service-worker fix(service-worker): Don't stay locked in EXISTING_CLIENTS_ONLY if corrupted data (#37453) 2020-06-08 09:31:34 -07:00
upgrade refactor(core): remove `looseIdentical` in favor of built-in `Object.is` (#37191) 2020-06-01 17:19:17 -04:00
zone.js refactor(dev-infra): small changes and fixes (#36800) 2020-06-03 13:12:30 -07:00
BUILD.bazel build: reference zone.js from source directly instead of npm. (#33046) 2019-11-06 00:48:34 +00:00
README.md docs: add doc reference to npm package readme (#33911) 2019-11-20 14:46:23 -08:00
circular-deps-test.conf.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
empty.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
goog.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
license-banner.txt build: bump year (#34651) 2020-01-13 07:21:43 -08:00
system.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
tsconfig-build-no-strict.json
tsconfig-build.json
tsconfig-test.json
tsconfig.json revert: "revert: "feat(dev-infra): exposed new rule 'component_benchmark' via dev_infra (#36434)" (#36798)" (#36800) 2020-06-03 13:12:30 -07:00
types.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00

README.md

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT