Add headless option to dump on disconnect

Summary:
This adds an optional exit strategy that reacts to the client disconnecting rather than a `SIGINT` which can be used for integration tests.

`MiddlewareAPI` is a subset of `Store` and required to work here.

Annoyingly, it's not quite clear to me why this does not work as part of an event loop cycle and requires a `setTimeout`. This doesn't have any negative effects and works in the same way that the SIGINT interruption works, but it's a bit of an eyesore.

Reviewed By: danielbuechele

Differential Revision: D14622111

fbshipit-source-id: e2caca056e478428d977565dc9bc09eefca4230c
This commit is contained in:
Pascal Hartig
2019-03-28 06:47:41 -07:00
committed by Facebook Github Bot
parent ddd06971f1
commit b20d0a4c8b
6 changed files with 58 additions and 28 deletions

View File

@@ -9,7 +9,7 @@ import type {
ElementID,
Element,
ElementSearchResultSet,
Store,
MiddlewareAPI,
PluginClient,
} from 'flipper';
@@ -61,7 +61,7 @@ export default class Layout extends FlipperPlugin<State, void, PersistedState> {
static exportPersistedState = (
callClient: (string, ?Object) => Promise<Object>,
persistedState: ?PersistedState,
store: ?Store,
store: ?MiddlewareAPI,
): Promise<?PersistedState> => {
const defaultPromise = Promise.resolve(persistedState);
if (!store) {