| 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 6d777135d9abc2b69d80448f8b652826872db08b..4a63ca3beaaeda001e13433919e889818d6b4d89 100644 | 
| --- a/sdk/lib/_internal/pub/lib/src/utils.dart | 
| +++ b/sdk/lib/_internal/pub/lib/src/utils.dart | 
| @@ -144,7 +144,14 @@ Future captureErrors(Future callback(), {bool captureStackChains: false}) { | 
| var wrappedCallback = () { | 
| new Future.sync(callback).then(completer.complete) | 
| .catchError((e, stackTrace) { | 
| -      completer.completeError(e, new Chain.forTrace(stackTrace)); | 
| +      // [stackTrace] can be null if we're running without [captureStackChains], | 
| +      // since dart:io will often throw errors without stack traces. | 
| +      if (stackTrace != null) { | 
| +        stackTrace = new Chain.forTrace(stackTrace); | 
| +      } else { | 
| +        stackTrace = new Chain([]); | 
| +      } | 
| +      completer.completeError(e, stackTrace); | 
| }); | 
| }; | 
|  | 
| @@ -152,7 +159,12 @@ Future captureErrors(Future callback(), {bool captureStackChains: false}) { | 
| Chain.capture(wrappedCallback, onError: completer.completeError); | 
| } else { | 
| runZoned(wrappedCallback, onError: (e, stackTrace) { | 
| -      completer.completeError(e, new Chain([new Trace.from(stackTrace)])); | 
| +      if (stackTrace == null) { | 
| +        stackTrace = new Chain([new Trace.from(stackTrace)]); | 
| +      } else { | 
| +        stackTrace = new Chain([]); | 
| +      } | 
| +      completer.completeError(e, stackTrace); | 
| }); | 
| } | 
|  | 
|  |