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
This commit is contained in:
Michel Weststrate
2021-09-30 01:32:53 -07:00
committed by Facebook GitHub Bot
parent 8fd012a8a3
commit b8236f1b3a
2 changed files with 12 additions and 3 deletions

View File

@@ -312,11 +312,15 @@ export default class Inspector extends Component<Props, State> {
): Promise<Array<Element>> {
if (ids.length > 0 && this.props.client.isConnected) {
const {forAccessibilityEvent} = options;
const {elements}: {elements: Array<Element>} =
await this.props.client.call(this.call().GET_NODES, {
const {elements}: {elements: Array<Element>} = 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 [];