mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* if a plugin fails to load, we will not crash grafana. * preventing the preloaded plugings to crash the whole app on failure. * updated to unkown. * fixed issue with angular by moving the preloadPlugin import to the same row as we did import the importPluginModule.
16 lines
532 B
TypeScript
16 lines
532 B
TypeScript
import { PreloadPlugin } from '@grafana/data';
|
|
import { importPluginModule } from './plugin_loader';
|
|
|
|
export async function preloadPlugins(pluginsToPreload: PreloadPlugin[] = []): Promise<void> {
|
|
await Promise.all(pluginsToPreload.map(preloadPlugin));
|
|
}
|
|
|
|
async function preloadPlugin(plugin: PreloadPlugin): Promise<void> {
|
|
const { path, version } = plugin;
|
|
try {
|
|
await importPluginModule(path, version);
|
|
} catch (error: unknown) {
|
|
console.error(`Failed to load plugin: ${path} (version: ${version})`, error);
|
|
}
|
|
}
|