From 362cea31264e17fa41f435e6c93853f954fa114a Mon Sep 17 00:00:00 2001 From: Lukas Kurucz Date: Wed, 15 Feb 2023 03:06:22 -0800 Subject: [PATCH] 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 --- js/js-flipper/src/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/js-flipper/src/client.ts b/js/js-flipper/src/client.ts index b64f134b8..60441f305 100644 --- a/js/js-flipper/src/client.ts +++ b/js/js-flipper/src/client.ts @@ -237,7 +237,7 @@ export class FlipperClient { }; this.ws.onclose = ({code}) => { // Some WS implementations do not properly set `wasClean` - if (code !== WSCloseCode.NormalClosure) { + if (![WSCloseCode.NormalClosure, WSCloseCode.GoingAway].includes(code)) { this.reconnect(); } };