angular-docs-cn/packages/service-worker/test
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
..
BUILD.bazel build: enable service-worker tests on saucelabs (#36129) 2020-04-01 15:37:47 -07:00
comm_spec.ts feat(service-worker): add `UnrecoverableStateError` (#36847) 2020-08-31 11:41:11 -07:00
integration_spec.ts feat(service-worker): add the option to prefer network for navigation requests (#38565) 2020-09-22 09:29:20 -07:00
module_spec.ts fix(service-worker): handle error with console.error (#40236) 2021-01-25 10:11:58 -08:00