Fix: WS should not reconnect on 1001 (#4506)
Summary: Due to bug in ReactNative `WebSocket` implementation, the `ws.close(1000)` method will not carry the provided `onclose` event number. It would close connection with `1001` instead. Technically, the `1001` also seems as normal status code to close WS connection, so likely we don't wanna use reconnect anyway. This only impacts older RN versions (iOS), as it was later fixed: https://github.com/facebook/react-native/pull/24950/files ## Changelog - Do not reconnect when WS close code is `1001` - GoingAway Pull Request resolved: https://github.com/facebook/flipper/pull/4506 Test Plan: Run `flipperClient.stop()`, then the connection should not be reconnected (only reproducible on RN env.) Reviewed By: lblasa Differential Revision: D43277366 Pulled By: passy fbshipit-source-id: bb39ec7debe53f15e75c850158188d56bf70375d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2e511b5d08
commit
362cea3126
@@ -237,7 +237,7 @@ export class FlipperClient {
|
|||||||
};
|
};
|
||||||
this.ws.onclose = ({code}) => {
|
this.ws.onclose = ({code}) => {
|
||||||
// Some WS implementations do not properly set `wasClean`
|
// Some WS implementations do not properly set `wasClean`
|
||||||
if (code !== WSCloseCode.NormalClosure) {
|
if (![WSCloseCode.NormalClosure, WSCloseCode.GoingAway].includes(code)) {
|
||||||
this.reconnect();
|
this.reconnect();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user