angular-docs-cn/packages/service-worker
Hoel IRIS 21bc16d4d8 fix(service-worker): handle error with console.error (#40236)
This commit reverts commit [_fix(service-worker): handle error with
ErrorHandler_](https://github.com/angular/angular/pull/39990/commits/552419d).

With Angular v11.0.4 and commit [_fix(service-worker): handle error with
ErrorHandler_](https://github.com/angular/angular/pull/39990/commits/552419d)
Angular start to send all service worker registration errors to the Angular
standard `ErrorHandler#handleError()` interface, instead of logging them in the
console.
But users existing `ErrorHandler#handleError()` implementations are not adapted
to service worker registration errors and it might result in broken apps or
bad UI.
Passing to `ErrorHandler` is desirable for some and undesirable for others and
the same is true for passing to `console.error()`.
But `console.error()` was used for a long time and thus it is preferable to keep
it as long as a good solution is not found with `ErrorHandler`.

Right now it's hard to define a good solution for `ErrorHandler` because:

1. Given the nature of the SW registration errors (usually outside the control
   of the developer, different error messages on each browser/version, often
   quite generic error messages, etc.), passing them to the `ErrorHandler` is
   not particularly helpful.
2. While `ErrorHandler#handleError()` accepts an argument of type `any` (so
   theoretically we could pass any object without changing the public API), most
   apps expect an `Error` instance, so many apps could break if we changed the
   shape.
3. Ideally, the Angular community want to re-think the `ErrorHandler` API
   and add support for being able to pass additional metadata for each error
   (such as the source of the error or some identifier, etc.). This change,
   however, could potentially affect many apps out there, so the community must
   put some thought into it and design it in a way that accounts for the needs
   of all packages (not just the SW).
4. Given that we want to more holistically revisit the `ErrorHandler` API, any
   changes we make in the short term to address the issue just for the SW will
   make it more difficult/breaky for people to move to a new API in the future.

To see the whole explanation see GitHub PR #40236.

PR Close #40236
2021-01-25 10:11:58 -08:00
..
cli docs: update links to use HTTPS as protocol (#39718) 2020-11-20 12:52:16 -08:00
config feat(service-worker): add the option to prefer network for navigation requests (#38565) 2020-09-22 09:29:20 -07:00
src fix(service-worker): handle error with console.error (#40236) 2021-01-25 10:11:58 -08:00
test fix(service-worker): handle error with console.error (#40236) 2021-01-25 10:11:58 -08:00
testing build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
worker refactor(service-worker): remove work-around for Chrome code highlighting bug (#40234) 2021-01-11 10:42:50 -08:00
BUILD.bazel refactor(dev-infra): ng_rollup_bundle rule should leverage `@bazel/rollup` (#37623) 2020-06-22 10:55:28 -07:00
PACKAGE.md docs: add package doc files (#26047) 2018-10-05 15:42:14 -07:00
index.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
package.json Revert "build: remove wombot proxy registry from package.jsons for release (#37378)" (#37495) 2020-06-10 08:21:45 -07:00
public_api.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
safety-worker.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00