Fix an edge case with nested Chain.capture blocks. Specifically, when a null stack trace is passed to a completer or stream controller in nested Chain.capture blocks, substitute the inner block's chain rather than the outer block's. This is consistent with other nested capture behavior, and it's useful for migrating to the new test runner. R=rnystrom@google.com Review URL: https://codereview.chromium.org//1171863002.
diff --git a/pkgs/stack_trace/CHANGELOG.md b/pkgs/stack_trace/CHANGELOG.md index 665eb30..d4696ec 100644 --- a/pkgs/stack_trace/CHANGELOG.md +++ b/pkgs/stack_trace/CHANGELOG.md
@@ -1,3 +1,9 @@ +## 1.3.3 + +* When a `null` stack trace is passed to a completer or stream controller in + nested `Chain.capture()` blocks, substitute the inner block's chain rather + than the outer block's. + ## 1.3.2 * Don't crash when running `Trace.terse` on empty stack traces.
diff --git a/pkgs/stack_trace/lib/src/stack_zone_specification.dart b/pkgs/stack_trace/lib/src/stack_zone_specification.dart index 0c1c7d2..25d9642 100644 --- a/pkgs/stack_trace/lib/src/stack_zone_specification.dart +++ b/pkgs/stack_trace/lib/src/stack_zone_specification.dart
@@ -172,12 +172,6 @@ /// necessary. AsyncError errorCallback(Zone self, ZoneDelegate parent, Zone zone, Object error, StackTrace stackTrace) { - var asyncError = parent.errorCallback(zone, error, stackTrace); - if (asyncError != null) { - error = asyncError.error; - stackTrace = asyncError.stackTrace; - } - // Go up two levels to get through [_CustomZone.errorCallback]. if (stackTrace == null) { stackTrace = _createNode(2).toChain(); @@ -185,7 +179,8 @@ if (_chains[stackTrace] == null) _chains[stackTrace] = _createNode(2); } - return new AsyncError(error, stackTrace); + var asyncError = parent.errorCallback(zone, error, stackTrace); + return asyncError == null ? new AsyncError(error, stackTrace) : asyncError; } /// Creates a [_Node] with the current stack trace and linked to
diff --git a/pkgs/stack_trace/pubspec.yaml b/pkgs/stack_trace/pubspec.yaml index bc3bc8d..f69417d 100644 --- a/pkgs/stack_trace/pubspec.yaml +++ b/pkgs/stack_trace/pubspec.yaml
@@ -7,7 +7,7 @@ # # When the major version is upgraded, you *must* update that version constraint # in pub to stay in sync with this. -version: 1.3.2 +version: 1.3.3-dev author: "Dart Team <misc@dartlang.org>" homepage: http://github.com/dart-lang/stack_trace description: >