Fix logs loosing connection occasionally
Summary: Changelog: Fixed an issue where Android logs would get stuck Our adb and rsocket connection are fundamentally unstable; every now and then it looses connection (at least on my machine). This happens both for emulators and real devices. If the logcat connection closes, it isn't restarted, so occassionaly the the logs would get 'stuck'. Fixed it by automatically restarting the stream if the close wasn't intentional. Investigated the stack of the disconnects, but it isn't caused on our end, the closures originate from (R)socket itself, so this band aid seems unavoidable. Using a near-zero timeout does work as well. Gave it a 100ms grace time though, in case starvation is a factor in the original problem. This might cause a few messages to be missed though, but it doesn't seem to happen to often (every few minutes in my case) Reviewed By: passy Differential Revision: D28095802 fbshipit-source-id: f22336ad46c04a3d886ff9dbc4d787591ac75eea
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1a8943e903
commit
ae65e2ccb8
@@ -79,6 +79,19 @@ export default class AndroidDevice extends BaseDevice {
|
||||
type,
|
||||
});
|
||||
})
|
||||
.on('end', () => {
|
||||
if (this.reader) {
|
||||
// logs didn't stop gracefully
|
||||
setTimeout(() => {
|
||||
if (this.connected.get()) {
|
||||
console.warn(
|
||||
`Log stream broken: ${this.serial} - restarting`,
|
||||
);
|
||||
this.startLogging();
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
})
|
||||
.on('error', (e) => {
|
||||
console.warn('Failed to read from adb logcat: ', e);
|
||||
});
|
||||
@@ -90,6 +103,7 @@ export default class AndroidDevice extends BaseDevice {
|
||||
|
||||
stopLogging() {
|
||||
this.reader?.end();
|
||||
this.reader = undefined;
|
||||
}
|
||||
|
||||
reverse(ports: [number, number]): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user