Centralise sessionId to a dedicated place

Summary:
The sessionId is just uuid() which is held by the config. This changes moves that to a single place.

This achieves two goals:
1) Makes it very clear where is created and what value it holds
2) It allows us to know the sessionId even before the config is available. This becomes useful as we can start logging to Scribe earlier.

Reviewed By: passy

Differential Revision: D48601829

fbshipit-source-id: c54d86d76f0b58d2b59f8dd1c45d7f345c4a84c3
This commit is contained in:
Lorenzo Blasa
2023-08-24 06:18:39 -07:00
committed by Facebook GitHub Bot
parent 6405a7bfdd
commit 1360e906f8
5 changed files with 20 additions and 6 deletions

View File

@@ -28,6 +28,7 @@ import {
loadLauncherSettings, loadLauncherSettings,
loadProcessConfig, loadProcessConfig,
loadSettings, loadSettings,
sessionId,
setupPrefetcher, setupPrefetcher,
startFlipperServer, startFlipperServer,
startServer, startServer,
@@ -39,7 +40,6 @@ import {
Logger, Logger,
parseEnvironmentVariables, parseEnvironmentVariables,
setLoggerInstance, setLoggerInstance,
uuid,
wrapRequire, wrapRequire,
} from 'flipper-common'; } from 'flipper-common';
import constants from './fb-stubs/constants'; import constants from './fb-stubs/constants';
@@ -167,7 +167,7 @@ async function getFlipperServer(
const getEmbeddedServer = async () => { const getEmbeddedServer = async () => {
const server = new FlipperServerImpl( const server = new FlipperServerImpl(
{ {
sessionId: uuid(), sessionId,
environmentInfo, environmentInfo,
env: parseEnvironmentVariables(env), env: parseEnvironmentVariables(env),
gatekeepers: gatekeepers, gatekeepers: gatekeepers,

View File

@@ -16,6 +16,7 @@ import {
loadLauncherSettings, loadLauncherSettings,
loadProcessConfig, loadProcessConfig,
loadSettings, loadSettings,
sessionId,
} from 'flipper-server-core'; } from 'flipper-server-core';
import { import {
ClientDescription, ClientDescription,
@@ -23,7 +24,6 @@ import {
DeviceDescription, DeviceDescription,
setLoggerInstance, setLoggerInstance,
parseEnvironmentVariables, parseEnvironmentVariables,
uuid,
} from 'flipper-common'; } from 'flipper-common';
import path from 'path'; import path from 'path';
import {stdout} from 'process'; import {stdout} from 'process';
@@ -95,7 +95,7 @@ async function start(deviceQuery: string, appName: string, pluginId: string) {
]); ]);
const server = new FlipperServerImpl( const server = new FlipperServerImpl(
{ {
sessionId: uuid(), sessionId,
environmentInfo, environmentInfo,
env: parseEnvironmentVariables(process.env), env: parseEnvironmentVariables(process.env),
gatekeepers: {}, gatekeepers: {},

View File

@@ -28,3 +28,5 @@ export {
getAuthToken, getAuthToken,
hasAuthToken, hasAuthToken,
} from './app-connectivity/certificate-exchange/certificate-utils'; } from './app-connectivity/certificate-exchange/certificate-utils';
export {sessionId} from './sessionId';

View File

@@ -13,7 +13,6 @@ import {
getLogger, getLogger,
FlipperServerType, FlipperServerType,
EnvironmentInfo, EnvironmentInfo,
uuid,
} from 'flipper-common'; } from 'flipper-common';
import path from 'path'; import path from 'path';
import fs from 'fs-extra'; import fs from 'fs-extra';
@@ -23,6 +22,7 @@ import {getGatekeepers} from '../gk';
import {loadLauncherSettings} from '../utils/launcherSettings'; import {loadLauncherSettings} from '../utils/launcherSettings';
import {loadProcessConfig} from '../utils/processConfig'; import {loadProcessConfig} from '../utils/processConfig';
import {loadSettings} from '../utils/settings'; import {loadSettings} from '../utils/settings';
import {sessionId} from '../sessionId';
/** /**
* Creates an instance of FlipperServer (FlipperServerImpl). This is the * Creates an instance of FlipperServer (FlipperServerImpl). This is the
@@ -59,7 +59,7 @@ export async function startFlipperServer(
]); ]);
return new FlipperServerImpl( return new FlipperServerImpl(
{ {
sessionId: uuid(), sessionId,
environmentInfo, environmentInfo,
env: parseEnvironmentVariables(process.env), env: parseEnvironmentVariables(process.env),
gatekeepers: getGatekeepers(environmentInfo.os.unixname), gatekeepers: getGatekeepers(environmentInfo.os.unixname),

View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {uuid} from 'flipper-common';
export const sessionId = uuid();