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:
committed by
Facebook Github Bot
parent
ddd06971f1
commit
b20d0a4c8b
@@ -5,7 +5,7 @@
|
||||
* @format
|
||||
*/
|
||||
import {getInstance as getLogger} from '../fb-stubs/Logger';
|
||||
import type {Store} from '../reducers';
|
||||
import type {Store, MiddlewareAPI} from '../reducers';
|
||||
import type {DeviceExport} from '../devices/BaseDevice';
|
||||
import type {State as PluginStates} from '../reducers/pluginStates';
|
||||
import type {PluginNotification} from '../reducers/notifications.js';
|
||||
@@ -183,7 +183,9 @@ export const processStore = async (
|
||||
return null;
|
||||
};
|
||||
|
||||
export async function getStoreExport(store: Store): Promise<?ExportType> {
|
||||
export async function getStoreExport(
|
||||
store: MiddlewareAPI,
|
||||
): Promise<?ExportType> {
|
||||
const state = store.getState();
|
||||
const {clients} = state.connections;
|
||||
const {pluginStates} = state;
|
||||
@@ -234,7 +236,7 @@ export async function getStoreExport(store: Store): Promise<?ExportType> {
|
||||
);
|
||||
}
|
||||
|
||||
export function exportStore(store: Store): Promise<string> {
|
||||
export function exportStore(store: MiddlewareAPI): Promise<string> {
|
||||
getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT);
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const storeExport = await getStoreExport(store);
|
||||
|
||||
Reference in New Issue
Block a user