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:
committed by
Facebook Github Bot
parent
825ecb8e23
commit
830c8067e4
37
src/utils/__tests__/promiseTimeout.node.js
Normal file
37
src/utils/__tests__/promiseTimeout.node.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
import promiseTimeout from '../promiseTimeout';
|
||||
|
||||
test('test promiseTimeout for timeout to happen', () => {
|
||||
let promise = promiseTimeout(
|
||||
200,
|
||||
new Promise((resolve, reject) => {
|
||||
let id = setTimeout(() => {
|
||||
clearTimeout(id);
|
||||
resolve();
|
||||
}, 500);
|
||||
return 'Executed';
|
||||
}),
|
||||
'Timed out',
|
||||
);
|
||||
return expect(promise).rejects.toThrow('Timed out');
|
||||
});
|
||||
|
||||
test('test promiseTimeout for timeout not to happen', () => {
|
||||
let promise = promiseTimeout(
|
||||
200,
|
||||
new Promise((resolve, reject) => {
|
||||
let id = setTimeout(() => {
|
||||
clearTimeout(id);
|
||||
resolve();
|
||||
}, 100);
|
||||
resolve('Executed');
|
||||
}),
|
||||
'Timed out',
|
||||
);
|
||||
return expect(promise).resolves.toBe('Executed');
|
||||
});
|
||||
Reference in New Issue
Block a user