Index: sdk/lib/_internal/pub/lib/src/utils.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/utils.dart b/sdk/lib/_internal/pub/lib/src/utils.dart |
index 4daec903e75bca57081a61caad8008ec9e37dba0..09575d7bf8e9e54d733ade12dfd87f3ab9adfc47 100644 |
--- a/sdk/lib/_internal/pub/lib/src/utils.dart |
+++ b/sdk/lib/_internal/pub/lib/src/utils.dart |
@@ -104,12 +104,14 @@ Future captureErrors(Future callback(), {bool captureStackChains: false}) { |
} else { |
stackTrace = new Chain([]); |
} |
- completer.completeError(e, stackTrace); |
+ if (!completer.isCompleted) completer.completeError(e, stackTrace); |
}); |
}; |
if (captureStackChains) { |
- Chain.capture(wrappedCallback, onError: completer.completeError); |
+ Chain.capture(wrappedCallback, onError: (error, stackTrace) { |
+ if (!completer.isCompleted) completer.completeError(error, stackTrace); |
+ }); |
} else { |
runZoned(wrappedCallback, onError: (e, stackTrace) { |
if (stackTrace == null) { |
@@ -117,7 +119,7 @@ Future captureErrors(Future callback(), {bool captureStackChains: false}) { |
} else { |
stackTrace = new Chain([new Trace.from(stackTrace)]); |
} |
- completer.completeError(e, stackTrace); |
+ if (!completer.isCompleted) completer.completeError(e, stackTrace); |
}); |
} |