From 23b551c8bf13070e00852f2ce2697bd1b95f3963 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Tue, 17 May 2022 04:20:30 -0700 Subject: [PATCH] Host and port as function args Summary: ^ Before this change, the client assumed the host and port came from location.host which is fine on the browser. In all other cases, that object/properties may be undefined. As such, add host and port as function args and use that instead. Reviewed By: passy Differential Revision: D36440423 fbshipit-source-id: 5f931f1d610d583db6a2e549e1213585f0d03dee --- .../flipper-frontend-core/src/client/FlipperServerClient.tsx | 4 +++- desktop/flipper-ui-browser/src/index.tsx | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/desktop/flipper-frontend-core/src/client/FlipperServerClient.tsx b/desktop/flipper-frontend-core/src/client/FlipperServerClient.tsx index 4b1d43f76..a64cfd519 100644 --- a/desktop/flipper-frontend-core/src/client/FlipperServerClient.tsx +++ b/desktop/flipper-frontend-core/src/client/FlipperServerClient.tsx @@ -25,6 +25,8 @@ export enum FlipperServerState { } export function createFlipperServer( + host: string, + port: number, onStateChange: (state: FlipperServerState) => void, ): Promise { onStateChange(FlipperServerState.CONNECTING); @@ -38,7 +40,7 @@ export function createFlipperServer( const eventEmitter = new EventEmitter(); - const socket = new ReconnectingWebSocket(`ws://${location.host}`); + const socket = new ReconnectingWebSocket(`ws://${host}:${port}`); const pendingRequests: Map< number, { diff --git a/desktop/flipper-ui-browser/src/index.tsx b/desktop/flipper-ui-browser/src/index.tsx index 4001f8fff..5a06cc8b2 100644 --- a/desktop/flipper-ui-browser/src/index.tsx +++ b/desktop/flipper-ui-browser/src/index.tsx @@ -28,6 +28,8 @@ async function start() { setLoggerInstance(logger); const flipperServer = await createFlipperServer( + location.hostname, + parseInt(location.port, 10), (state: FlipperServerState) => { switch (state) { case FlipperServerState.CONNECTING: