From 1d6fc9e3acaef9a35df8911bdfa9f67dcf7724fc Mon Sep 17 00:00:00 2001 From: John Knox Date: Tue, 17 Sep 2019 09:00:29 -0700 Subject: [PATCH] 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 --- src/dispatcher/iOSDevice.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/dispatcher/iOSDevice.tsx b/src/dispatcher/iOSDevice.tsx index 816f639a6..9f5f16a37 100644 --- a/src/dispatcher/iOSDevice.tsx +++ b/src/dispatcher/iOSDevice.tsx @@ -149,6 +149,18 @@ function getActiveDevices(): Promise> { }); } +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; async function checkXcodeVersionMismatch() { if (xcodeVersionMismatchFound) { @@ -196,14 +208,5 @@ export default (store: Store, logger: Logger) => { if (process.platform !== 'darwin') { return; } - queryDevices(store, logger) - .then(() => { - const simulatorUpdateInterval = setInterval(() => { - queryDevices(store, logger).catch(err => { - console.error(err); - clearInterval(simulatorUpdateInterval); - }); - }, 3000); - }) - .catch(console.error); + queryDevicesForever(store, logger); };