Create a partial universal export in case of errors

Summary:
Design doc: https://docs.google.com/document/d/1HLCFl46RfqG0o1mSt8SWrwf_HMfOCRg_oENioc1rkvQ/edit#

Attach what we can to the universal export file if any of the steps time out

CHANGELOG: Add a universal debug export button

Reviewed By: passy

Differential Revision: D40552235

fbshipit-source-id: 775afccacf053fbcf764d1f39e93a89ad20dee0a
This commit is contained in:
Andrey Goncharov
2022-10-25 05:31:48 -07:00
committed by Facebook GitHub Bot
parent e886427003
commit 2289d6c0e2
2 changed files with 55 additions and 38 deletions

View File

@@ -471,9 +471,7 @@ function ExportEverythingEverywhereAllAtOnceButton() {
<p>Exporting Flipper debug files from all devices...</p>
<p>It could take a long time!</p>
<p>Let's count sheep while we wait: {sheepCount++}.</p>
<p>
Scream for help if the sheep count reaches 42, but not earlier.
</p>
<p>We'll skip it automatically if it exceeds 3 minutes.</p>
</>,
);
};
@@ -491,14 +489,14 @@ function ExportEverythingEverywhereAllAtOnceButton() {
<p>Exporting Flipper state...</p>
<p>It also could take a long time!</p>
<p>This time we could count dinosaurs: {dinosaursCount++}.</p>
<p>You already know what to do when the counter reaches 42.</p>
<p>We'll skip it automatically if it exceeds 2 minutes.</p>
</>,
);
};
setStateExportMessage();
const interval = setInterval(setStateExportMessage, 1000);
const interval = setInterval(setStateExportMessage, 2000);
return () => clearInterval(interval);
}
case 'archive': {

View File

@@ -8,7 +8,12 @@
*/
import * as React from 'react';
import {getLogger, DeviceDebugFile, DeviceDebugCommand} from 'flipper-common';
import {
getLogger,
DeviceDebugFile,
DeviceDebugCommand,
timeout,
} from 'flipper-common';
import {Store, MiddlewareAPI} from '../reducers';
import {DeviceExport} from 'flipper-frontend-core';
import {selectedPlugins, State as PluginsState} from '../reducers/plugins';
@@ -643,6 +648,7 @@ export async function exportEverythingEverywhereAllAtOnce(
zip.file('flipper_logs.txt', serializedLogs);
try {
// Step 2: Export device logs
onStatusUpdate?.('files');
const flipperFolderContent = await startDeviceFlipperFolderExport();
@@ -671,16 +677,29 @@ export async function exportEverythingEverywhereAllAtOnce(
}
});
});
} catch (e) {
console.error(
'exportEverythingEverywhereAllAtOnce -> failed to export Flipper device debug data',
e,
);
}
try {
// Step 3: Export Flipper State
onStatusUpdate?.('state');
const exportablePlugins = getExportablePlugins(store.getState());
// TODO: no need to put this in the store,
// need to be cleaned up later in combination with SupportForm
store.dispatch(selectedPlugins(exportablePlugins.map(({id}) => id)));
const {serializedString} = await exportStore(store);
const {serializedString} = await timeout(2 * 60 * 1000, exportStore(store));
zip.file('flipper_export', serializedString);
} catch (e) {
console.error(
'exportEverythingEverywhereAllAtOnce -> failed to export Flipper state',
e,
);
}
onStatusUpdate?.('archive');
const archiveData = await zip.generateAsync({type: 'uint8array'});