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
@@ -70,6 +70,7 @@ export class FlipperServerImpl implements FlipperServer {
|
||||
readonly disposers: ((() => void) | void)[] = [];
|
||||
private readonly devices = new Map<string, ServerDevice>();
|
||||
state: FlipperServerState = 'pending';
|
||||
stateError: string | undefined = undefined;
|
||||
android: AndroidDeviceManager;
|
||||
ios: IOSDeviceManager;
|
||||
keytarManager: KeytarManager;
|
||||
@@ -136,11 +137,14 @@ export class FlipperServerImpl implements FlipperServer {
|
||||
|
||||
setServerState(state: FlipperServerState, error?: Error) {
|
||||
this.state = state;
|
||||
this.emit('server-state', {state, error});
|
||||
this.stateError = '' + error;
|
||||
this.emit('server-state', {state, error: this.stateError});
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts listening to parts and watching for devices
|
||||
* Starts listening to parts and watching for devices.
|
||||
* Connect never throws directly, but communicates
|
||||
* through server-state events
|
||||
*/
|
||||
async connect() {
|
||||
if (this.state !== 'pending') {
|
||||
@@ -225,6 +229,10 @@ export class FlipperServerImpl implements FlipperServer {
|
||||
}
|
||||
|
||||
private commandHandler: FlipperServerCommands = {
|
||||
'get-server-state': async () => ({
|
||||
state: this.state,
|
||||
error: this.stateError,
|
||||
}),
|
||||
'node-api-exec': commandNodeApiExec,
|
||||
'node-api-fs-access': access,
|
||||
'node-api-fs-pathExists': async (path, mode) => {
|
||||
|
||||
Reference in New Issue
Block a user