Make device debug info fetching fault tolerant
Summary: Design doc: https://docs.google.com/document/d/1HLCFl46RfqG0o1mSt8SWrwf_HMfOCRg_oENioc1rkvQ/edit# Some files on the devices could be unavailable due to lack of permissions (hello SELinux and enterprise builds of iOS apps). Instead of failing the export, we should fetch what we can. Reviewed By: passy Differential Revision: D40551931 fbshipit-source-id: 698e157b1283b9e959909b6439cd09d2dc8dc8d6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
80f947212b
commit
e886427003
@@ -25,6 +25,7 @@ import {
|
|||||||
FlipperServerConfig,
|
FlipperServerConfig,
|
||||||
Logger,
|
Logger,
|
||||||
FlipperServerExecOptions,
|
FlipperServerExecOptions,
|
||||||
|
DeviceDebugData,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import {ServerDevice} from './devices/ServerDevice';
|
import {ServerDevice} from './devices/ServerDevice';
|
||||||
import {Base64} from 'js-base64';
|
import {Base64} from 'js-base64';
|
||||||
@@ -611,10 +612,21 @@ export class FlipperServerImpl implements FlipperServer {
|
|||||||
(device.info.os === 'Android' || device.info.os === 'iOS'),
|
(device.info.os === 'Android' || device.info.os === 'iOS'),
|
||||||
)
|
)
|
||||||
.map((device) =>
|
.map((device) =>
|
||||||
(device as unknown as DebuggableDevice).readFlipperFolderForAllApps(),
|
(device as unknown as DebuggableDevice)
|
||||||
|
.readFlipperFolderForAllApps()
|
||||||
|
|
||||||
|
.catch((e) => {
|
||||||
|
console.warn(
|
||||||
|
'fetchDebugLogs -> could not fetch debug data',
|
||||||
|
device.info.serial,
|
||||||
|
e,
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return debugDataForEachDevice.flat();
|
return debugDataForEachDevice
|
||||||
|
.filter((item): item is DeviceDebugData[] => !!item)
|
||||||
|
.flat();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async close() {
|
public async close() {
|
||||||
|
|||||||
@@ -315,7 +315,8 @@ export default class AndroidDevice
|
|||||||
this.info.serial,
|
this.info.serial,
|
||||||
appId,
|
appId,
|
||||||
`find /data/data/${appId}/files/sonar -type f -printf "%f\n"`,
|
`find /data/data/${appId}/files/sonar -type f -printf "%f\n"`,
|
||||||
).then((output) => {
|
)
|
||||||
|
.then((output) => {
|
||||||
if (output.includes('No such file or directory')) {
|
if (output.includes('No such file or directory')) {
|
||||||
console.debug(
|
console.debug(
|
||||||
'AndroidDevice.readFlipperFolderForAllApps -> skipping app because sonar dir does not exist',
|
'AndroidDevice.readFlipperFolderForAllApps -> skipping app because sonar dir does not exist',
|
||||||
@@ -332,6 +333,14 @@ export default class AndroidDevice
|
|||||||
// As a result, there is an "" (empty string) item at the end after the split.
|
// As a result, there is an "" (empty string) item at the end after the split.
|
||||||
.filter((appId) => appId !== '')
|
.filter((appId) => appId !== '')
|
||||||
);
|
);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.debug(
|
||||||
|
'AndroidDevice.readFlipperFolderForAllApps -> failed to fetch sonar dir',
|
||||||
|
this.info.serial,
|
||||||
|
appId,
|
||||||
|
e,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!sonarDirFileNames) {
|
if (!sonarDirFileNames) {
|
||||||
@@ -349,7 +358,12 @@ export default class AndroidDevice
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
path: filePath,
|
path: filePath,
|
||||||
data: await pull(this.adb, this.info.serial, appId, filePath),
|
data: await pull(
|
||||||
|
this.adb,
|
||||||
|
this.info.serial,
|
||||||
|
appId,
|
||||||
|
filePath,
|
||||||
|
).catch((e) => `Couldn't pull the file: ${e}`),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -183,6 +183,8 @@ export default class IOSDevice
|
|||||||
data: '===SECURE_CONTENT===',
|
data: '===SECURE_CONTENT===',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
// See iOSCertificateProvider to learn why we need 2 pulls
|
||||||
try {
|
try {
|
||||||
await this.iOSBridge.pull(
|
await this.iOSBridge.pull(
|
||||||
this.info.serial,
|
this.info.serial,
|
||||||
@@ -206,7 +208,7 @@ export default class IOSDevice
|
|||||||
path.join(dir, fileName),
|
path.join(dir, fileName),
|
||||||
);
|
);
|
||||||
console.debug(
|
console.debug(
|
||||||
'IOSDevice.readFlipperFolderForAllApps -> Subsequent idb pull succeeded. Nevermind previous wranings.',
|
'IOSDevice.readFlipperFolderForAllApps -> Subsequent idb pull succeeded. Nevermind previous warnings.',
|
||||||
this.info.serial,
|
this.info.serial,
|
||||||
userApp.bundleID,
|
userApp.bundleID,
|
||||||
fileName,
|
fileName,
|
||||||
@@ -219,6 +221,12 @@ export default class IOSDevice
|
|||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
} catch (e) {
|
||||||
|
return {
|
||||||
|
path: filePath,
|
||||||
|
data: `Couldn't pull the file: ${e}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user