Plugins: Send SystemJS import errors to Faro

This commit is contained in:
Giuseppe Guerra 2024-10-09 16:34:56 +02:00
parent 818ff761cc
commit a17d2865ae

View File

@ -23,6 +23,7 @@ import { SystemJSWithLoaderHooks } from './loader/types';
import { buildImportMap, resolveModulePath } from './loader/utils';
import { importPluginModuleInSandbox } from './sandbox/sandbox_plugin_loader';
import { isFrontendSandboxSupported } from './sandbox/utils';
import { pluginsLogger } from './utils';
const imports = buildImportMap(sharedDependenciesMap);
@ -118,7 +119,18 @@ export async function importPluginModule({
return importPluginModuleInSandbox({ pluginId });
}
return SystemJS.import(modulePath);
return SystemJS.import(modulePath).catch((e) => {
let error = new Error('Could not load plugin: ' + e);
console.error(error);
pluginsLogger.logError(error, {
path,
pluginId,
pluginVersion: version ?? '',
expectedHash: moduleHash ?? '',
sriChecksEnabled: (config.featureToggles.pluginsSriChecks ?? false).toString(),
});
throw error;
});
}
export function importDataSourcePlugin(meta: DataSourcePluginMeta): Promise<GenericDataSourcePlugin> {