diff --git a/desktop/app/src/dispatcher/plugins.tsx b/desktop/app/src/dispatcher/plugins.tsx index 5a855c24b..c02b57315 100644 --- a/desktop/app/src/dispatcher/plugins.tsx +++ b/desktop/app/src/dispatcher/plugins.tsx @@ -162,45 +162,61 @@ export async function getDynamicPlugins() { export const checkGK = (gatekeepedPlugins: Array) => ( plugin: ActivatablePluginDetails, ): boolean => { - if (!plugin.gatekeeper) { - return true; + try { + if (!plugin.gatekeeper) { + return true; + } + const result = GK.get(plugin.gatekeeper); + if (!result) { + gatekeepedPlugins.push(plugin); + } + return result; + } catch (err) { + console.error(`Failed to check GK for plugin ${plugin.id}`, err); + return false; } - const result = GK.get(plugin.gatekeeper); - if (!result) { - gatekeepedPlugins.push(plugin); - } - return result; }; export const checkDisabled = ( disabledPlugins: Array, ) => { - const enabledList = process.env.FLIPPER_ENABLED_PLUGINS - ? new Set(process.env.FLIPPER_ENABLED_PLUGINS.split(',')) - : null; + let enabledList: Set | null = null; let disabledList: Set = new Set(); try { + if (process.env.FLIPPER_ENABLED_PLUGINS) { + enabledList = new Set( + process.env.FLIPPER_ENABLED_PLUGINS.split(','), + ); + } disabledList = config().disabledPlugins; } catch (e) { - console.error(e); + console.error('Failed to compute enabled/disabled plugins', e); } return (plugin: ActivatablePluginDetails): boolean => { - if (disabledList.has(plugin.name)) { - disabledPlugins.push(plugin); + try { + if (disabledList.has(plugin.name)) { + disabledPlugins.push(plugin); + return false; + } + if ( + enabledList && + !( + enabledList.has(plugin.name) || + enabledList.has(plugin.id) || + enabledList.has(plugin.name.replace('flipper-plugin-', '')) + ) + ) { + disabledPlugins.push(plugin); + return false; + } + return true; + } catch (e) { + console.error( + `Failed to check whether plugin ${plugin.id} is disabled`, + e, + ); return false; } - if ( - enabledList && - !( - enabledList.has(plugin.name) || - enabledList.has(plugin.id) || - enabledList.has(plugin.name.replace('flipper-plugin-', '')) - ) - ) { - disabledPlugins.push(plugin); - return false; - } - return true; }; };