Fix uncaught exception in adb logging

Summary:
Found some random unhandled rejection. Added error catching / logging to adb logcat setup.
{F558587842}

Reviewed By: passy

Differential Revision: D27429914

fbshipit-source-id: faca682819a2f1a3f924ee176cc9f8c9f92f5ae9
This commit is contained in:
Michel Weststrate
2021-03-31 01:38:58 -07:00
committed by Facebook GitHub Bot
parent 7e9346e736
commit 238374f4db

View File

@@ -44,9 +44,12 @@ export default class AndroidDevice extends BaseDevice {
} }
startLogging() { startLogging() {
this.adb.openLogcat(this.serial, {clear: true}).then((reader) => { this.adb
.openLogcat(this.serial, {clear: true})
.then((reader) => {
this.reader = reader; this.reader = reader;
reader.on('entry', (entry) => { reader
.on('entry', (entry) => {
let type: LogLevel = 'unknown'; let type: LogLevel = 'unknown';
if (entry.priority === Priority.VERBOSE) { if (entry.priority === Priority.VERBOSE) {
type = 'verbose'; type = 'verbose';
@@ -75,7 +78,13 @@ export default class AndroidDevice extends BaseDevice {
date: entry.date, date: entry.date,
type, type,
}); });
})
.on('error', (e) => {
console.warn('Failed to read from adb logcat: ', e);
}); });
})
.catch((e) => {
console.warn('Failed to open log stream: ', e);
}); });
} }