Don't make simultaneous ios device queries

Summary:
Fixes this:
https://fb.workplace.com/groups/967178219989117/permalink/3178405185533065/

Reviewed By: passy

Differential Revision: D17421166

fbshipit-source-id: 6ee14a05d157063d7646076175b6cdaf918a7caa
This commit is contained in:
John Knox
2019-09-17 09:00:29 -07:00
committed by Facebook Github Bot
parent 199658aeef
commit 1d6fc9e3ac

View File

@@ -149,6 +149,18 @@ function getActiveDevices(): Promise<Array<IOSDeviceParams>> {
}); });
} }
function queryDevicesForever(store: Store, logger: Logger) {
queryDevices(store, logger)
.then(() => {
// It's important to schedule the next check AFTER the current one has completed
// to avoid simultaneous queries which can cause multiple user input prompts.
setTimeout(() => queryDevicesForever(store, logger), 3000);
})
.catch(err => {
console.error(err);
});
}
let xcodeVersionMismatchFound = false; let xcodeVersionMismatchFound = false;
async function checkXcodeVersionMismatch() { async function checkXcodeVersionMismatch() {
if (xcodeVersionMismatchFound) { if (xcodeVersionMismatchFound) {
@@ -196,14 +208,5 @@ export default (store: Store, logger: Logger) => {
if (process.platform !== 'darwin') { if (process.platform !== 'darwin') {
return; return;
} }
queryDevices(store, logger) queryDevicesForever(store, logger);
.then(() => {
const simulatorUpdateInterval = setInterval(() => {
queryDevices(store, logger).catch(err => {
console.error(err);
clearInterval(simulatorUpdateInterval);
});
}, 3000);
})
.catch(console.error);
}; };