Fixes an issue whereas token was only obtained if one exists

Summary: The token will be generated if one doesn't exist, so always call get token.

Reviewed By: antonk52

Differential Revision: D50494884

fbshipit-source-id: b93ba8ab5ba0c8b48766af3b06e8de94944d08e7
This commit is contained in:
Lorenzo Blasa
2023-10-20 04:59:41 -07:00
committed by Facebook GitHub Bot
parent 450e6f2d7c
commit a8be443670

View File

@@ -112,19 +112,6 @@ async function getFlipperServer(
);
const keytar: KeytarModule | undefined = await getKeytarModule(staticPath);
const port = 52342;
/**
* Only attempt to use the auth token if one is available. Otherwise,
* trying to get the auth token will try to generate one if it does not exist.
* At this state, it would be impossible to generate it as our certificates
* may not be available yet.
*/
let token: string | undefined;
if (await hasAuthToken()) {
token = await getAuthToken();
}
const searchParams = new URLSearchParams(token ? {token} : {});
const TCPconnectionURL = new URL(`ws://localhost:${port}?${searchParams}`);
async function shutdown(): Promise<boolean> {
console.info('[flipper-server] Attempt to shutdown.');
@@ -173,6 +160,10 @@ async function getFlipperServer(
environmentInfo,
);
const token: string = await getAuthToken();
const searchParams = new URLSearchParams({token});
const TCPconnectionURL = new URL(`ws://localhost:${port}?${searchParams}`);
const companionEnv = await initCompanionEnv(server);
await server.connect();
await readyForIncomingConnections(server, companionEnv);