| Index: utils/pub/io.dart
|
| diff --git a/utils/pub/io.dart b/utils/pub/io.dart
|
| index 0309b90d9af0cc55fd32cb1a2c42f721b7135e30..8754706c31c42c135ef513e56cbd3d0a5ece97f1 100644
|
| --- a/utils/pub/io.dart
|
| +++ b/utils/pub/io.dart
|
| @@ -599,7 +599,18 @@ class _OutputStreamConsumer implements StreamConsumer<List<int>, dynamic> {
|
| // the following TODO.
|
| var completed = false;
|
| var completer = new Completer();
|
| - stream.listen((data) => _outputStream.write(data), onDone: () {
|
| + stream.listen((data) {
|
| + // Writing empty data to a closed stream can cause errors.
|
| + if (data.isEmpty) return;
|
| +
|
| + // TODO(nweiz): remove this try/catch when issue 7836 is fixed.
|
| + try {
|
| + _outputStream.write(data);
|
| + } catch (e, stack) {
|
| + if (!completed) completer.completeError(e, stack);
|
| + completed = true;
|
| + }
|
| + }, onDone: () {
|
| _outputStream.close();
|
| // TODO(nweiz): wait until _outputStream.onClosed is called once issue
|
| // 7761 is fixed.
|
|
|