angular-docs-cn/packages/upgrade/static/src
Sam Julien 0ddf2e7a5b fix(upgrade): do not break if `onMicrotaskEmpty` emits while a `$digest` is in progress (#29794)
Previously, under certain circumstances, `NgZone#onMicrotaskEmpty` could
emit while a `$digest` was in progress, thus triggering another
`$digest`, which in turn would throw a `$digest already in progress`
error. Furthermore, throwing an error from inside the `onMicrotaskEmpty`
subscription would result in unsubscribing and stop triggering further
`$digest`s, when `onMicrotaskEmpty` emitted.

Usually, emitting while a `$digest` was already in progress was a result
of unintentionally running some part of AngularJS outside the Angular
zone, but there are valid (if rare) usecases where this can happen
(see #24680 for details).

This commit addresses the issue as follows:
- If a `$digest` is in progress when `onMicrotaskEmpty` emits, do not
  trigger another `$digest` (to avoid the error). `$evalAsync()` is used
  instead, to ensure that the bindings are evaluated at least once more.
- Since there is still a high probability that the situation is a result
  of programming error (i.e. some AngularJS part running outside the
  Angular Zone), a warning will be logged, but only if the app is in
  [dev mode][1].

[1]: https://github.com/angular/angular/blob/78146c189/packages/core/src/util/ng_dev_mode.ts#L12

Fixes #24680

PR Close #29794
2019-04-25 11:00:36 -07:00
..
angular1_providers.ts refactor(upgrade): use Bazel packages to avoid symlinks in the source (#29466) 2019-04-02 10:38:01 -07:00
downgrade_module.ts refactor(upgrade): rename `module` constant to avoid webpack bug (#30058) 2019-04-24 17:03:51 -07:00
upgrade_component.ts refactor(upgrade): use Bazel packages to avoid symlinks in the source (#29466) 2019-04-02 10:38:01 -07:00
upgrade_module.ts fix(upgrade): do not break if `onMicrotaskEmpty` emits while a `$digest` is in progress (#29794) 2019-04-25 11:00:36 -07:00
util.ts refactor(upgrade): use Bazel packages to avoid symlinks in the source (#29466) 2019-04-02 10:38:01 -07:00