From d81a9909e07cd150b87754e1d0c80342178f8293 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Wed, 9 Feb 2022 04:21:47 -0800 Subject: [PATCH] Fix error that is logged when device disconnected quickly Summary: If a device disconnects quickly, trying to determine whether screenshots and alike are supported would throw, showing up in our monitoring (see attached tasks). This change fixes that Reviewed By: nikoant Differential Revision: D34105451 fbshipit-source-id: 8d3d6dd4c2c82f70cdff710722d789e7c1d73693 --- desktop/flipper-server-core/src/FlipperServerImpl.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/desktop/flipper-server-core/src/FlipperServerImpl.tsx b/desktop/flipper-server-core/src/FlipperServerImpl.tsx index 616098144..100a8887e 100644 --- a/desktop/flipper-server-core/src/FlipperServerImpl.tsx +++ b/desktop/flipper-server-core/src/FlipperServerImpl.tsx @@ -333,9 +333,13 @@ export class FlipperServerImpl implements FlipperServer { return Array.from(this.devices.values()).map((d) => d.info); }, 'device-supports-screenshot': async (serial: string) => - this.getDevice(serial).screenshotAvailable(), + this.devices.has(serial) + ? this.getDevice(serial).screenshotAvailable() + : false, 'device-supports-screencapture': async (serial: string) => - this.getDevice(serial).screenCaptureAvailable(), + this.devices.has(serial) + ? this.getDevice(serial).screenCaptureAvailable() + : false, 'device-take-screenshot': async (serial: string) => Base64.fromUint8Array(await this.getDevice(serial).screenshot()), 'device-start-screencapture': async (serial, destination) =>