Attach connection handler earlier
Summary: This change attaches our event handlers as soon as the ws is created. As a consequence, we need to wait until the server has created any necessary instances required to process incoming requests. To achieve this, I created a type called `Lazy`. This type wraps around a value and a promise to that value. Callers can check if the value is set. If not, callers can wait for it. Ultimately, the value can be set outside of the promise itself. Reviewed By: passy Differential Revision: D37284939 fbshipit-source-id: 17dec548d7155a3d65440c9584cec07cbb826c37
This commit is contained in:
committed by
Facebook GitHub Bot
parent
40e65901bd
commit
8c67b049ab
@@ -16,7 +16,6 @@ import {
|
||||
} from 'flipper-plugin';
|
||||
import {createFlipperServer, FlipperServerState} from 'flipper-frontend-core';
|
||||
import {
|
||||
attachSocketServer,
|
||||
FlipperServerImpl,
|
||||
getEnvironmentInfo,
|
||||
getGatekeepers,
|
||||
@@ -93,13 +92,13 @@ async function getFlipperServer(
|
||||
if (!(await checkSocketInUse(socketPath))) {
|
||||
console.info('flipper-server: not running/listening, start');
|
||||
|
||||
const {socket} = await startServer({
|
||||
const {readyForIncomingConnections} = await startServer({
|
||||
port: 52342,
|
||||
staticDir: staticPath,
|
||||
entry: 'index.web.dev.html',
|
||||
});
|
||||
|
||||
const flipperServer = await startFlipperServer(
|
||||
const server = await startFlipperServer(
|
||||
appPath,
|
||||
staticPath,
|
||||
'',
|
||||
@@ -107,10 +106,10 @@ async function getFlipperServer(
|
||||
keytar,
|
||||
);
|
||||
|
||||
const companionEnv = await initCompanionEnv(flipperServer);
|
||||
await flipperServer.connect();
|
||||
const companionEnv = await initCompanionEnv(server);
|
||||
await server.connect();
|
||||
|
||||
attachSocketServer(flipperServer, socket, companionEnv);
|
||||
await readyForIncomingConnections(server, companionEnv);
|
||||
} else {
|
||||
console.info('flipper-server: already running');
|
||||
const loggerOutputFile = 'flipper-server-log.out';
|
||||
|
||||
Reference in New Issue
Block a user