From b8236f1b3aff66fdc1b26cef6ca049dad38c1edb Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Thu, 30 Sep 2021 01:32:53 -0700 Subject: [PATCH] Don't leave rejection unhandled if node fetching fails Summary: Fix potentially unhandled promise rejection in Layout inspector. Not really reproducible, and probably originating from old Flipper versions (no trace is available either), since we have a lot of connection check in place. Just in case still handled the exception, for example if something goes wrong on client side Reviewed By: passy Differential Revision: D31267465 fbshipit-source-id: d1b384db7bb010af8d2aa12ae29110f343fb14af --- desktop/plugins/public/layout/Inspector.tsx | 8 ++++++-- desktop/plugins/public/layout/index.tsx | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/desktop/plugins/public/layout/Inspector.tsx b/desktop/plugins/public/layout/Inspector.tsx index f88fa2ad7..44632e03e 100644 --- a/desktop/plugins/public/layout/Inspector.tsx +++ b/desktop/plugins/public/layout/Inspector.tsx @@ -312,11 +312,15 @@ export default class Inspector extends Component { ): Promise> { if (ids.length > 0 && this.props.client.isConnected) { const {forAccessibilityEvent} = options; - const {elements}: {elements: Array} = - await this.props.client.call(this.call().GET_NODES, { + const {elements}: {elements: Array} = await this.props.client + .call(this.call().GET_NODES, { ids, forAccessibilityEvent, selected: false, + }) + .catch((e) => { + console.error(`[Layout] Failed to fetch nodes from app:`, e); + return {elements: []}; }); if (!elements) { return []; diff --git a/desktop/plugins/public/layout/index.tsx b/desktop/plugins/public/layout/index.tsx index 03c416544..2c3cd848f 100644 --- a/desktop/plugins/public/layout/index.tsx +++ b/desktop/plugins/public/layout/index.tsx @@ -110,7 +110,12 @@ export default class LayoutPlugin extends FlipperPlugin< callClient, 'getNodes', supportsMethod, - ); + ).catch((e) => { + console.error( + `[Layout] Failed to fetch Nodes from app while creating export`, + e, + ); + }); } const AXelements: ElementMap = {}; if (rootAXElement) {