Fix the edge case to export and import broken export

Summary:
This diff fixes the broken export which is being made [here](https://fb.workplace.com/groups/graphqlandroid/permalink/3319822971399628/). In the import there is no client and plugin states. The fact that the validation succeeded on submit button click suggests that the app got disconnected between the click on submit button and the initiation of export, thus exporting the store with no plugin data and client.

I have added a validation after exporting the store and before the trace is uploaded.

Also in the support request details page, we assumed that client can't be null,  relaxed this assumption as the flipper should still open even the above broken export instead of crashing.

Reviewed By: mweststrate

Differential Revision: D20136295

fbshipit-source-id: f589d01f8ff0ec0b23d53ad5099e11ebbd0930cd
This commit is contained in:
Pritesh Nandgaonkar
2020-02-28 00:02:06 -08:00
committed by Facebook Github Bot
parent f44d2e4560
commit 74e1376089

View File

@@ -26,7 +26,7 @@ import {
import {default as BaseDevice} from '../devices/BaseDevice'; import {default as BaseDevice} from '../devices/BaseDevice';
import {default as ArchivedDevice} from '../devices/ArchivedDevice'; import {default as ArchivedDevice} from '../devices/ArchivedDevice';
import fs from 'fs'; import fs from 'fs';
import uuid from 'uuid'; import {v4 as uuidv4} from 'uuid';
import {remote, OpenDialogOptions} from 'electron'; import {remote, OpenDialogOptions} from 'electron';
import {readCurrentRevision} from './packageMetadata'; import {readCurrentRevision} from './packageMetadata';
import {tryCatchReportPlatformFailures} from './metrics'; import {tryCatchReportPlatformFailures} from './metrics';
@@ -591,7 +591,7 @@ export async function getStoreExport(
clients: client ? [client.toJSON()] : [], clients: client ? [client.toJSON()] : [],
devicePlugins, devicePlugins,
clientPlugins, clientPlugins,
salt: uuid.v4(), salt: uuidv4(),
selectedPlugins: state.plugins.selectedPlugins, selectedPlugins: state.plugins.selectedPlugins,
statusUpdate, statusUpdate,
}, },
@@ -605,7 +605,11 @@ export async function exportStore(
includeSupportDetails?: boolean, includeSupportDetails?: boolean,
idler?: Idler, idler?: Idler,
statusUpdate?: (msg: string) => void, statusUpdate?: (msg: string) => void,
): Promise<{serializedString: string; errorArray: Array<Error>}> { ): Promise<{
serializedString: string;
errorArray: Array<Error>;
exportStoreData: ExportType | null;
}> {
getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT); getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT);
performance.mark(EXPORT_FLIPPER_TRACE_TIME_SERIALIZATION_EVENT); performance.mark(EXPORT_FLIPPER_TRACE_TIME_SERIALIZATION_EVENT);
statusUpdate && statusUpdate('Preparing to export Flipper data...'); statusUpdate && statusUpdate('Preparing to export Flipper data...');
@@ -647,9 +651,13 @@ export async function exportStore(
}); });
console.error('Export Store Task Failures: ', errorStr); console.error('Export Store Task Failures: ', errorStr);
} }
return {serializedString, errorArray}; return {serializedString, errorArray, exportStoreData: exportData};
} else { } else {
return {serializedString: '{}', errorArray: []}; return {
serializedString: '{}',
errorArray: [],
exportStoreData: exportData,
};
} }
} }