Skip to content

Commit 979ad8b

Browse files
committed
Log usbmux connection state changes
1 parent 0aadb6c commit 979ad8b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/interceptors/frida/frida-ios-integration.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,22 @@ const isDevicePortOpen = (usbmuxClient: UsbmuxClient, deviceId: number, port: nu
2222
return false;
2323
});
2424

25-
// We scan frequently, but we don't want to spam the logs, so we just log the first
26-
// time that we fail to reach Usbmux (just for general reference of any issues).
27-
let loggedUsbmuxFailure = false;
25+
// We scan frequently, but we don't want to spam the logs, so we just log each time
26+
// Usbmux changes state (just for general reference of any issues).
27+
let lastUsbmuxState: boolean | undefined = undefined;
2828

2929
export async function getIosFridaHosts(usbmuxClient: UsbmuxClient): Promise<Record<string, FridaHost>> {
30-
const devices = await usbmuxClient.getDevices().catch((e) => {
31-
if (!loggedUsbmuxFailure) {
30+
const devices = await usbmuxClient.getDevices()
31+
.then((devices) => {
32+
if (!lastUsbmuxState) {
33+
console.log('Usbmux iOS scanning connected');
34+
lastUsbmuxState = true;
35+
}
36+
return devices;
37+
}).catch((e) => {
38+
if (lastUsbmuxState !== false) {
3239
console.log('Usbmux iOS scanning failed:', e.message);
33-
loggedUsbmuxFailure = true;
40+
lastUsbmuxState = false;
3441
}
3542
return [];
3643
});

0 commit comments

Comments
 (0)