mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 11:34:23 +00:00
Updating Websocket readyState in case of websocketFailed event
Summary: Fix for https://github.com/facebook/react-native/issues/9465 We are building a react-native based application which extensively uses WebSockets. The Android app crashes right after waking up being in suspended mode for a coupe of days and throws an exception: "Cannot send a message. Unknown WebSocket id 1" Before calling WebSocket.send(...) method from WebSocket.js we always check its readyState. I believe the problem is caused by not updating readyState if case of 'websocketFailed' event. this.close() cause the current used websocket ID to be removed from mWebSocketConnections HashMap (WebSocketModule.java), but readyState stays the same. Closes https://github.com/facebook/react-native/pull/9487 Differential Revision: D3838675 Pulled By: mkonicek fbshipit-source-id: e833cef9f1b94c6f7236077241cacf5a56f5824b
This commit is contained in:
parent
b0c13ebe02
commit
6b42d5c952
@ -189,6 +189,7 @@ class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) {
|
||||
if (ev.id !== this._socketId) {
|
||||
return;
|
||||
}
|
||||
this.readyState = this.CLOSED;
|
||||
this.dispatchEvent(new WebSocketEvent('error', {
|
||||
message: ev.message,
|
||||
}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user