Make sure flipper server initialization errors are propagated properly
Summary: This diff makes sure that errors are propagated similarly in flipper desktop and browser version, and that they are shown in either case. Since in the browser version, the UI loads after the error happened, we'll store the error so that any client connecting in the future will read and report it. Also added a `--failFast` flag to flipper-server, so that the process exits immediately if misconfigured, which is convenient in CI use cases and such Reviewed By: nikoant Differential Revision: D33348922 fbshipit-source-id: 0f584104f881141fde38da3f0031748415343ea2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8259f92983
commit
b6c884f011
@@ -7,6 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import process from 'process';
|
||||
import chalk from 'chalk';
|
||||
import path from 'path';
|
||||
import {startFlipperServer} from './startFlipperServer';
|
||||
@@ -37,6 +38,12 @@ const argv = yargs
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
failFast: {
|
||||
describe:
|
||||
'Exit the process immediately if the server cannot start, for example due to an incorrect configuration.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
.version('DEV')
|
||||
.help()
|
||||
@@ -64,12 +71,19 @@ async function start() {
|
||||
staticDir,
|
||||
entry: 'index.web.dev.html',
|
||||
});
|
||||
const flipperServer = await startFlipperServer(rootDir, staticDir);
|
||||
if (argv.failFast) {
|
||||
flipperServer.on('server-state', ({state}) => {
|
||||
if (state === 'error') {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
await flipperServer.connect();
|
||||
|
||||
const [flipperServer] = await Promise.all([
|
||||
startFlipperServer(rootDir, staticDir),
|
||||
argv.bundler ? startWebServerDev(app, server, socket, rootDir) : undefined,
|
||||
]);
|
||||
|
||||
if (argv.bundler) {
|
||||
await startWebServerDev(app, server, socket, rootDir);
|
||||
}
|
||||
startSocketServer(flipperServer, socket);
|
||||
}
|
||||
|
||||
@@ -85,6 +99,6 @@ start()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(chalk.red('Server error: '), e);
|
||||
console.error(chalk.red('Server startup error: '), e);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user