Timeout promise while exporting flipper plugin

Summary:
Added a promiseTimeout util so that we limit the time taken to export flipper plugin. I had received a feedback from the user stating that that the loader for the export stays for ages and never finishes. So this diff adds a timeout to the promise which is returned by `exportPersistedState` function. This function is currently implemented just by Layout inspector to fetch the entire view hierarchy. I suspect the the former mentioned bug may be due to the unresponsive client.

This diff also shows the plugin and the client information for which `exportPersistedState` timed out. Also this will hopefully solve the problem surfaced recently stating that the bug report gets stuck, the reason for which I suspect would be the same as the above mentioned reason, because we export flipper data when we create a bug report.

Reviewed By: danielbuechele

Differential Revision: D14712633

fbshipit-source-id: 35f8cfa722ec3b7ff94ebda943d618834ac3207d
This commit is contained in:
Pritesh Nandgaonkar
2019-04-04 04:17:20 -07:00
committed by Facebook Github Bot
parent 825ecb8e23
commit 830c8067e4
6 changed files with 166 additions and 37 deletions

View File

@@ -101,8 +101,8 @@ function startFlipper({
// current eventloop task here.
setTimeout(() => {
exportStore(store)
.then(output => {
originalConsole.log(output);
.then(({serializedString}) => {
originalConsole.log(serializedString);
process.exit();
})
.catch(console.error);
@@ -122,7 +122,9 @@ function startFlipper({
if (exit == 'sigint') {
process.on('SIGINT', async () => {
try {
originalConsole.log(await exportStore(store));
const {serializedString, errorArray} = await exportStore(store);
errorArray.forEach(console.error);
originalConsole.log(serializedString);
} catch (e) {
console.error(e);
}