Fix bug where client plugins weren't always started

Summary:
Changelog: Fixed issue where occasionally a plugin wouldn't open after starting Flipper

This fixes a long standing issue where rarely Flipper wouldn't show the selected plugin. This turned out to be a raise condition, that was easy to reproduce in the Flipper browser version; if a client register before all the plugins are loaded, the plugins that are enabled for that client, but not loaded yet, will not instantiate and hence not show up. This diff fixes that

Reviewed By: timur-valiev, aigoncharov

Differential Revision: D32987162

fbshipit-source-id: f3179cd9b6f2e4e79d05be1f2236f63acdf50495
This commit is contained in:
Michel Weststrate
2021-12-10 17:58:06 -08:00
committed by Facebook GitHub Bot
parent bb23b36051
commit fa67c21def
7 changed files with 43 additions and 24 deletions

View File

@@ -46,6 +46,7 @@ import {
isFlipperMessageDebuggingEnabled,
registerFlipperDebugMessage,
} from './chrome/FlipperMessages';
import {waitFor} from './utils/waitFor';
type Plugins = Set<string>;
type PluginsArr = Array<string>;
@@ -173,6 +174,8 @@ export default class Client extends EventEmitter {
async init() {
await this.loadPlugins();
// if a client arrives before all plugins are loaded, we'll have to wait
await waitFor(this.store, (state) => state.plugins.initialized);
// this starts all sandy enabled plugins
this.plugins.forEach((pluginId) =>
this.startPluginIfNeeded(this.getPlugin(pluginId)),