From 33962d4fa4ba116a4b0ca199f57fdf9158cce016 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 6 Oct 2023 03:26:14 -0700 Subject: [PATCH] Get token before opening Summary: Get the authentication token before an open as either browser or PWA. There could be cases whereas the PWA gets launched first before the token is exported to the manifest and thus it makes it not possible to connect on a first launch. Reviewed By: antonk52 Differential Revision: D50004992 fbshipit-source-id: d58b7a75dcb9aaf7fadd3e3c3a773581441f9d92 --- desktop/flipper-server/src/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/desktop/flipper-server/src/index.tsx b/desktop/flipper-server/src/index.tsx index 392529c51..93507ad15 100644 --- a/desktop/flipper-server/src/index.tsx +++ b/desktop/flipper-server/src/index.tsx @@ -292,15 +292,17 @@ async function start() { async function launch() { console.info('[flipper-server] Launch UI'); + const token = await getAuthToken(); + console.info( + `[flipper-server] Get authentication token: ${token?.length != 0}`, + ); + if (!argv.open) { return; } const openInBrowser = async () => { console.info('[flipper-server] Open in browser'); - const token = await getAuthToken(); - - console.info('[flipper-server] Token is available:', token !== undefined); const searchParams = new URLSearchParams({token: token ?? ''}); const url = new URL(`http://localhost:${argv.port}?${searchParams}`);