Index: sdk/lib/io/websocket_impl.dart |
diff --git a/sdk/lib/io/websocket_impl.dart b/sdk/lib/io/websocket_impl.dart |
index cc68544e536233a5e43d63a699e01d4d58ce5b4e..af5f8426c983db0bc28902cb4bb5a82f4111f8d9 100644 |
--- a/sdk/lib/io/websocket_impl.dart |
+++ b/sdk/lib/io/websocket_impl.dart |
@@ -857,6 +857,13 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket { |
[this._serverSide = false]) { |
_consumer = new _WebSocketConsumer(this, _socket); |
_sink = new _StreamSinkImpl(_consumer); |
+ _sink.done.catchError((e) { |
+ if (!_controller.isClosed) { |
+ _close(WebSocketStatus.ABNORMAL_CLOSURE); |
+ _controller.addError(e); |
+ _controller.close(); |
+ } |
+ }); |
_readyState = WebSocket.OPEN; |
var transformer = new _WebSocketProtocolTransformer(_serverSide); |
@@ -993,6 +1000,10 @@ class _WebSocketImpl extends Stream with _ServiceObject implements WebSocket { |
_outCloseCode = code; |
_outCloseReason = reason; |
} |
+ if (_closeCode == null) { |
+ _closeCode = code; |
+ _closeReason = reason; |
+ } |
_writeClosed = true; |
_consumer.closeSocket(); |
_webSockets.remove(_serviceId); |