Tolerate individual plugin load errors
Summary: This diff fixes the issue when there is an error on checking GK for any of plugins and because of it the entire set of plugins failed to load. Each plugin should be loaded in isolation from others. Reviewed By: passy Differential Revision: D26099735 fbshipit-source-id: ba5475f4baf2d06f8922d345c9d401f5b15956ec
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e104a1fa6b
commit
1ce619af7e
@@ -162,6 +162,7 @@ export async function getDynamicPlugins() {
|
|||||||
export const checkGK = (gatekeepedPlugins: Array<ActivatablePluginDetails>) => (
|
export const checkGK = (gatekeepedPlugins: Array<ActivatablePluginDetails>) => (
|
||||||
plugin: ActivatablePluginDetails,
|
plugin: ActivatablePluginDetails,
|
||||||
): boolean => {
|
): boolean => {
|
||||||
|
try {
|
||||||
if (!plugin.gatekeeper) {
|
if (!plugin.gatekeeper) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -170,21 +171,29 @@ export const checkGK = (gatekeepedPlugins: Array<ActivatablePluginDetails>) => (
|
|||||||
gatekeepedPlugins.push(plugin);
|
gatekeepedPlugins.push(plugin);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Failed to check GK for plugin ${plugin.id}`, err);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const checkDisabled = (
|
export const checkDisabled = (
|
||||||
disabledPlugins: Array<ActivatablePluginDetails>,
|
disabledPlugins: Array<ActivatablePluginDetails>,
|
||||||
) => {
|
) => {
|
||||||
const enabledList = process.env.FLIPPER_ENABLED_PLUGINS
|
let enabledList: Set<string> | null = null;
|
||||||
? new Set<string>(process.env.FLIPPER_ENABLED_PLUGINS.split(','))
|
|
||||||
: null;
|
|
||||||
let disabledList: Set<string> = new Set();
|
let disabledList: Set<string> = new Set();
|
||||||
try {
|
try {
|
||||||
|
if (process.env.FLIPPER_ENABLED_PLUGINS) {
|
||||||
|
enabledList = new Set<string>(
|
||||||
|
process.env.FLIPPER_ENABLED_PLUGINS.split(','),
|
||||||
|
);
|
||||||
|
}
|
||||||
disabledList = config().disabledPlugins;
|
disabledList = config().disabledPlugins;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error('Failed to compute enabled/disabled plugins', e);
|
||||||
}
|
}
|
||||||
return (plugin: ActivatablePluginDetails): boolean => {
|
return (plugin: ActivatablePluginDetails): boolean => {
|
||||||
|
try {
|
||||||
if (disabledList.has(plugin.name)) {
|
if (disabledList.has(plugin.name)) {
|
||||||
disabledPlugins.push(plugin);
|
disabledPlugins.push(plugin);
|
||||||
return false;
|
return false;
|
||||||
@@ -201,6 +210,13 @@ export const checkDisabled = (
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
console.error(
|
||||||
|
`Failed to check whether plugin ${plugin.id} is disabled`,
|
||||||
|
e,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user