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,24 +315,33 @@ 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) => {
|
)
|
||||||
if (output.includes('No such file or directory')) {
|
.then((output) => {
|
||||||
|
if (output.includes('No such file or directory')) {
|
||||||
|
console.debug(
|
||||||
|
'AndroidDevice.readFlipperFolderForAllApps -> skipping app because sonar dir does not exist',
|
||||||
|
this.info.serial,
|
||||||
|
appId,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
output
|
||||||
|
.split('\n')
|
||||||
|
// Each entry has \n at the end. The last one also has it.
|
||||||
|
// As a result, there is an "" (empty string) item at the end after the split.
|
||||||
|
.filter((appId) => appId !== '')
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
console.debug(
|
console.debug(
|
||||||
'AndroidDevice.readFlipperFolderForAllApps -> skipping app because sonar dir does not exist',
|
'AndroidDevice.readFlipperFolderForAllApps -> failed to fetch sonar dir',
|
||||||
this.info.serial,
|
this.info.serial,
|
||||||
appId,
|
appId,
|
||||||
|
e,
|
||||||
);
|
);
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
output
|
|
||||||
.split('\n')
|
|
||||||
// Each entry has \n at the end. The last one also has it.
|
|
||||||
// As a result, there is an "" (empty string) item at the end after the split.
|
|
||||||
.filter((appId) => appId !== '')
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!sonarDirFileNames) {
|
if (!sonarDirFileNames) {
|
||||||
return;
|
return;
|
||||||
@@ -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}`),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -184,41 +184,49 @@ export default class IOSDevice
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.iOSBridge.pull(
|
// See iOSCertificateProvider to learn why we need 2 pulls
|
||||||
this.info.serial,
|
try {
|
||||||
filePath,
|
await this.iOSBridge.pull(
|
||||||
userApp.bundleID,
|
this.info.serial,
|
||||||
dir,
|
filePath,
|
||||||
);
|
userApp.bundleID,
|
||||||
|
dir,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.debug(
|
||||||
|
'IOSDevice.readFlipperFolderForAllApps -> Original idb pull failed. Most likely it is a physical device that requires us to handle the dest path dirrently. Forcing a re-try with the updated dest path. See D32106952 for details. Original error:',
|
||||||
|
this.info.serial,
|
||||||
|
userApp.bundleID,
|
||||||
|
fileName,
|
||||||
|
filePath,
|
||||||
|
e,
|
||||||
|
);
|
||||||
|
await this.iOSBridge.pull(
|
||||||
|
this.info.serial,
|
||||||
|
filePath,
|
||||||
|
userApp.bundleID,
|
||||||
|
path.join(dir, fileName),
|
||||||
|
);
|
||||||
|
console.debug(
|
||||||
|
'IOSDevice.readFlipperFolderForAllApps -> Subsequent idb pull succeeded. Nevermind previous warnings.',
|
||||||
|
this.info.serial,
|
||||||
|
userApp.bundleID,
|
||||||
|
fileName,
|
||||||
|
filePath,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
path: filePath,
|
||||||
|
data: await readFile(path.join(dir, fileName), {
|
||||||
|
encoding: 'utf-8',
|
||||||
|
}),
|
||||||
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug(
|
return {
|
||||||
'IOSDevice.readFlipperFolderForAllApps -> Original idb pull failed. Most likely it is a physical device that requires us to handle the dest path dirrently. Forcing a re-try with the updated dest path. See D32106952 for details. Original error:',
|
path: filePath,
|
||||||
this.info.serial,
|
data: `Couldn't pull the file: ${e}`,
|
||||||
userApp.bundleID,
|
};
|
||||||
fileName,
|
|
||||||
filePath,
|
|
||||||
e,
|
|
||||||
);
|
|
||||||
await this.iOSBridge.pull(
|
|
||||||
this.info.serial,
|
|
||||||
filePath,
|
|
||||||
userApp.bundleID,
|
|
||||||
path.join(dir, fileName),
|
|
||||||
);
|
|
||||||
console.debug(
|
|
||||||
'IOSDevice.readFlipperFolderForAllApps -> Subsequent idb pull succeeded. Nevermind previous wranings.',
|
|
||||||
this.info.serial,
|
|
||||||
userApp.bundleID,
|
|
||||||
fileName,
|
|
||||||
filePath,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return {
|
|
||||||
path: filePath,
|
|
||||||
data: await readFile(path.join(dir, fileName), {
|
|
||||||
encoding: 'utf-8',
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user