From 45644aab354f3ed8dc835c81e53c62f26163ce30 Mon Sep 17 00:00:00 2001 From: Yuri Zarubin Date: Wed, 14 Oct 2015 08:16:09 -0700 Subject: [PATCH] Check that WS connection is open before closing it on failed. Fixes #3346 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Check that the WS state is set to OPEN before trying to close it when the ```websocketFailed``` event fires. Otherwise the app throws an error at the Android level. Fixes #3346 Closes https://github.com/facebook/react-native/pull/3347 Reviewed By: @​svcscm Differential Revision: D2535807 Pulled By: @mkonicek fb-gh-sync-id: bb70c551ea2e582cfaa80139a265dbbca6d990d2 --- Libraries/WebSocket/WebSocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/WebSocket/WebSocket.js b/Libraries/WebSocket/WebSocket.js index 5751f0f84..a328aa5b4 100644 --- a/Libraries/WebSocket/WebSocket.js +++ b/Libraries/WebSocket/WebSocket.js @@ -115,7 +115,7 @@ class WebSocket extends WebSocketBase { this.onerror && this.onerror(event); this.dispatchEvent(event); this._unregisterEvents(); - this._closeWebSocket(id); + this.readyState === this.OPEN && this._closeWebSocket(id); }) ]; }