From e32a377c65d13637b6b3d2f0a8bacd753659cb5d Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Wed, 29 Sep 2021 06:55:40 -0700 Subject: [PATCH] Fix eagerly rejection ADB spawn error Summary: Fix unnecessary unhandled promise rejection. Reviewed By: passy Differential Revision: D31267305 fbshipit-source-id: 90b22fdfa1721f10ad92dbeca74c2ee1988ac15c --- .../app/src/server/utils/CertificateProvider.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/desktop/app/src/server/utils/CertificateProvider.tsx b/desktop/app/src/server/utils/CertificateProvider.tsx index 20c04ae8b..8551502f2 100644 --- a/desktop/app/src/server/utils/CertificateProvider.tsx +++ b/desktop/app/src/server/utils/CertificateProvider.tsx @@ -99,7 +99,10 @@ export default class CertificateProvider { get adb(): Promise { if (this.config.enableAndroid) { - return this._adb!; + if (this._adb) { + return this._adb; + } + throw new Error(`ADB initialisation was not not successful`); } throw new Error('Android is not enabled in settings'); } @@ -114,14 +117,15 @@ export default class CertificateProvider { this._adb = config.enableAndroid ? (getAdbClient(config).catch((e) => { // make sure initialization failure is already logged + const msg = + 'Failed to initialise ADB. Please disabled Android supportin settings, or configure a correct path'; message.error({ duration: 10, - content: - 'Failed to initialise ADB. Please check your Android settings, ANDROID_HOME and run the Setup Doctor. ' + - e, + content: msg + e, }); - console.error('Failed to initialise ADB', e); - this._adb = Promise.reject(e); + // eslint-disable-next-line flipper/no-console-error-without-context + console.error(msg, e); + this._adb = undefined; // no adb client available }) as Promise) : undefined; if (isTest()) {