Index: runtime/bin/socket_patch.dart |
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart |
index 27329f139abece776673f92b4604f1e6b353c515..2d1044dafd52027f54a74c88abc4751a54da4680 100644 |
--- a/runtime/bin/socket_patch.dart |
+++ b/runtime/bin/socket_patch.dart |
@@ -1179,7 +1179,13 @@ class _SocketStreamConsumer extends StreamConsumer<List<int>> { |
assert(buffer == null); |
buffer = data; |
offset = 0; |
- write(); |
+ try { |
+ write(); |
+ } catch (e) { |
+ stop(); |
+ socket._consumerDone(); |
+ done(e); |
+ } |
}, |
onError: (error, [stackTrace]) { |
socket._consumerDone(); |
@@ -1199,28 +1205,22 @@ class _SocketStreamConsumer extends StreamConsumer<List<int>> { |
} |
void write() { |
- try { |
- if (subscription == null) return; |
- assert(buffer != null); |
- // Write as much as possible. |
- offset += socket._write(buffer, offset, buffer.length - offset); |
- if (offset < buffer.length) { |
- if (!paused) { |
- paused = true; |
- subscription.pause(); |
- } |
- socket._enableWriteEvent(); |
- } else { |
- buffer = null; |
- if (paused) { |
- paused = false; |
- subscription.resume(); |
- } |
+ if (subscription == null) return; |
+ assert(buffer != null); |
+ // Write as much as possible. |
+ offset += socket._write(buffer, offset, buffer.length - offset); |
+ if (offset < buffer.length) { |
+ if (!paused) { |
+ paused = true; |
+ subscription.pause(); |
+ } |
+ socket._enableWriteEvent(); |
+ } else { |
+ buffer = null; |
+ if (paused) { |
+ paused = false; |
+ subscription.resume(); |
} |
- } catch (e) { |
- stop(); |
- socket._consumerDone(); |
- done(e); |
} |
} |