Try catch more to see actual error

This commit is contained in:
Peter Hedenskog 2025-01-31 15:16:49 +01:00
parent 3f15b9b942
commit 201d9d0b75
1 changed files with 59 additions and 56 deletions

View File

@ -80,63 +80,66 @@ export async function run(options) {
packageJson.dependencies.browsertime,
packageJson.dependencies['coach-core']
);
log.debug('Running with options: %:2j', options);
let pluginNames = await parsePluginNames(options);
const plugins = options.plugins;
// Deprecated setup
if (plugins) {
if (plugins.disable) {
log.warn('--plugins.disable is deprecated, use plugins.remove instead.');
plugins.remove = plugins.disable;
}
if (plugins.load) {
log.warn('--plugins.load is deprecated, use plugins.add instead.');
plugins.add = plugins.load;
}
// Finalize the plugins that we wanna run
// First we add the new ones and then remove, that means remove
// always wins
pluginNames = [...new Set([...pluginNames, ...toArray(plugins.add)])];
const removeSet = new Set(toArray(plugins.remove));
pluginNames = pluginNames.filter(name => !removeSet.has(name));
if (plugins.list) {
log.info('The following plugins are enabled: %s', pluginNames.join(', '));
}
}
// This is the contect where we wanna run our tests
const context = {
storageManager,
resultUrls,
timestamp,
budget: budgetResult,
name: url,
log,
getLogger,
messageMaker,
statsHelpers,
filterRegistry
};
const queueHandler = new QueueHandler(options);
const runningPlugins = await loadPlugins(
pluginNames,
options,
context,
queueHandler
);
const urlSources = [options.multi ? scriptSource : urlSource];
const allPlugins = [...runningPlugins];
queueHandler.setup(runningPlugins);
// Open/start each and every plugin
try {
log.debug('Running with options: %:2j', options);
let pluginNames = await parsePluginNames(options);
const plugins = options.plugins;
// Deprecated setup
if (plugins) {
if (plugins.disable) {
log.warn(
'--plugins.disable is deprecated, use plugins.remove instead.'
);
plugins.remove = plugins.disable;
}
if (plugins.load) {
log.warn('--plugins.load is deprecated, use plugins.add instead.');
plugins.add = plugins.load;
}
// Finalize the plugins that we wanna run
// First we add the new ones and then remove, that means remove
// always wins
pluginNames = [...new Set([...pluginNames, ...toArray(plugins.add)])];
const removeSet = new Set(toArray(plugins.remove));
pluginNames = pluginNames.filter(name => !removeSet.has(name));
if (plugins.list) {
log.info(
'The following plugins are enabled: %s',
pluginNames.join(', ')
);
}
}
// This is the contect where we wanna run our tests
const context = {
storageManager,
resultUrls,
timestamp,
budget: budgetResult,
name: url,
log,
getLogger,
messageMaker,
statsHelpers,
filterRegistry
};
const queueHandler = new QueueHandler(options);
const runningPlugins = await loadPlugins(
pluginNames,
options,
context,
queueHandler
);
const urlSources = [options.multi ? scriptSource : urlSource];
const allPlugins = [...runningPlugins];
queueHandler.setup(runningPlugins);
// Open/start each and every plugin
await Promise.all(
runOptionalFunction(allPlugins, 'open', context, options)
);