From e51e95af2ec42b448cc9c663cfc2697797607a43 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Fri, 13 May 2022 06:40:06 -0700 Subject: [PATCH] supportsMethod should return false if not connected Summary: https://www.internalfb.com/logview/details/flipper_javascript/7e72d9f75d047791d9de43b72915cbd4/?selected-logview-tab=latest shows an exception for just checking whether a feature is supported, while the client is not connected. there is no point in checking if a feature is supported if not connected, so just returning false instead of throwing Reviewed By: timur-valiev Differential Revision: D36371047 fbshipit-source-id: 6e83bed6fc53cc41ddef30eeeb41d030b2c4c175 --- desktop/flipper-frontend-core/src/AbstractClient.tsx | 3 +++ desktop/flipper-plugin/src/plugin/Plugin.tsx | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop/flipper-frontend-core/src/AbstractClient.tsx b/desktop/flipper-frontend-core/src/AbstractClient.tsx index ec410664f..48b6d5638 100644 --- a/desktop/flipper-frontend-core/src/AbstractClient.tsx +++ b/desktop/flipper-frontend-core/src/AbstractClient.tsx @@ -503,6 +503,9 @@ export default abstract class AbstractClient extends EventEmitter { } async supportsMethod(api: string, method: string): Promise { + if (!this.connected.get()) { + return false; + } const response = await this.rawCall<{ isSupported: boolean; }>('isMethodSupported', true, { diff --git a/desktop/flipper-plugin/src/plugin/Plugin.tsx b/desktop/flipper-plugin/src/plugin/Plugin.tsx index f9645b015..aa8aa4d44 100644 --- a/desktop/flipper-plugin/src/plugin/Plugin.tsx +++ b/desktop/flipper-plugin/src/plugin/Plugin.tsx @@ -207,7 +207,6 @@ export class SandyPluginInstance extends BasePluginInstance { this.events.on('unhandled-event', batched(cb)); }, supportsMethod: async (method) => { - this.assertConnected(); return await realClient.supportsMethod( this.definition.id, method as any,