Make sure Flipper server startup errors are propagated for desktop

Summary:
If openssl is not available, this would lead to an unhandled rejection exception. That is because a lot initialization logic generates promises that don't get a catch chained on immediately. Changed the flipper server startup flow to be more idiomatically async

Fixes https://github.com/facebook/flipper/issues/2766

Changelog: More clearly communicate if flipper server failed to start (e.d. due to port already taken, openssl not being available)

This change fixes it only for desktop flipper, will make sure the browser UI will support this as well (the error will fire correctly there, but there are no listeners during startup)

Reviewed By: nikoant

Differential Revision: D33348923

fbshipit-source-id: f561bb27b18a3041c514b37f7aed11435a49647f
This commit is contained in:
Michel Weststrate
2022-01-04 02:56:33 -08:00
committed by Facebook GitHub Bot
parent 7f944ae946
commit 8259f92983
3 changed files with 70 additions and 89 deletions

View File

@@ -96,7 +96,6 @@ async function start() {
keytar,
);
await flipperServer.connect();
const flipperServerConfig = await flipperServer.exec('get-config');
initializeElectron(flipperServer, flipperServerConfig);
@@ -110,6 +109,8 @@ async function start() {
// eslint-disable-next-line import/no-commonjs
require('flipper-ui-core').startFlipperDesktop(flipperServer);
await flipperServer.connect();
// Initialize launcher
setupPrefetcher(flipperServerConfig.settings);
}