Fix idb device duplicates
Summary: idb sometimes returns duplicates when we query targets. It leads us to removing valid devices and reconnecting to them again. Eventually, it starves the idb thread pool. This diff removes the duplicates from the idb output. Reviewed By: jknoxville Differential Revision: D32099320 fbshipit-source-id: 7d8b756360f82557000ea5aa037a249b33be9961
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2e7015388c
commit
bffd58b3a6
@@ -97,7 +97,7 @@ export async function queryTargetsWithoutXcodeDependency(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseIdbTargets(lines: string): Array<DeviceTarget> {
|
function parseIdbTargets(lines: string): Array<DeviceTarget> {
|
||||||
return lines
|
const parsedIdbTargets = lines
|
||||||
.trim()
|
.trim()
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map((line) => line.trim())
|
.map((line) => line.trim())
|
||||||
@@ -113,6 +113,15 @@ function parseIdbTargets(lines: string): Array<DeviceTarget> {
|
|||||||
type: target.type as DeviceType,
|
type: target.type as DeviceType,
|
||||||
name: target.name,
|
name: target.name,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// For some reason, idb can return duplicates
|
||||||
|
// TODO: Raise the issue with idb
|
||||||
|
const dedupedIdbTargets: Record<string, DeviceTarget> = {};
|
||||||
|
for (const idbTarget of parsedIdbTargets) {
|
||||||
|
dedupedIdbTargets[idbTarget.udid] =
|
||||||
|
dedupedIdbTargets[idbTarget.udid] ?? idbTarget;
|
||||||
|
}
|
||||||
|
return Object.values(dedupedIdbTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function idbListTargets(
|
export async function idbListTargets(
|
||||||
|
|||||||
@@ -133,12 +133,16 @@ export class IOSDeviceManager {
|
|||||||
const config = getFlipperServerConfig();
|
const config = getFlipperServerConfig();
|
||||||
const isXcodeInstalled = await iosUtil.isXcodeDetected();
|
const isXcodeInstalled = await iosUtil.isXcodeDetected();
|
||||||
const isIdbAvailable = await iosUtil.isAvailable(config.idbPath);
|
const isIdbAvailable = await iosUtil.isAvailable(config.idbPath);
|
||||||
|
console.debug(
|
||||||
|
`[conn] queryDevices. isXcodeInstalled ${isXcodeInstalled}, isIdbAvailable ${isIdbAvailable}`,
|
||||||
|
);
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
this.getAllPromisesForQueryingDevices(isXcodeInstalled, isIdbAvailable),
|
this.getAllPromisesForQueryingDevices(isXcodeInstalled, isIdbAvailable),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private processDevices(activeDevices: IOSDeviceParams[]) {
|
private processDevices(activeDevices: IOSDeviceParams[]) {
|
||||||
|
console.debug('[conn] processDevices', activeDevices);
|
||||||
if (!this.iosBridge) {
|
if (!this.iosBridge) {
|
||||||
throw new Error('iOS bridge not yet initialized');
|
throw new Error('iOS bridge not yet initialized');
|
||||||
}
|
}
|
||||||
@@ -148,6 +152,10 @@ export class IOSDeviceManager {
|
|||||||
.filter((device) => device.info.os === 'iOS')
|
.filter((device) => device.info.os === 'iOS')
|
||||||
.map((device) => device.serial),
|
.map((device) => device.serial),
|
||||||
);
|
);
|
||||||
|
console.debug(
|
||||||
|
'[conn] processDevices -> currentDeviceIDs',
|
||||||
|
currentDeviceIDs,
|
||||||
|
);
|
||||||
|
|
||||||
for (const activeDevice of activeDevices) {
|
for (const activeDevice of activeDevices) {
|
||||||
const {udid, type, name} = activeDevice;
|
const {udid, type, name} = activeDevice;
|
||||||
|
|||||||
Reference in New Issue
Block a user