Merge branch 'main' into better-error-handling

This commit is contained in:
Peter Hedenskog 2025-03-10 10:49:01 +01:00 committed by GitHub
commit 65ab729673
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 11 deletions

View File

@ -185,7 +185,7 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
// https://github.com/sitespeedio/sitespeed.io/issues/2341
for (const element of result) {
// Browsertime supports alias for URLS in a script
const alias = element.info.alias;
const alias = element.info?.alias;
if (alias) {
if (this.scriptOrMultiple) {
url = element.info.url;
@ -207,14 +207,32 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
resultIndex++
) {
axeAggregatorPerURL = new AxeAggregator(this.options);
// Send errors from Browsertime as early as possible
// Check for errors. Browsertime errors is an array of all iterations
// [[],[],[]] where one iteration can have multiple errors
for (let errorsForOneIteration of result[resultIndex].errors) {
if (Array.isArray(errorsForOneIteration)) {
for (let error of errorsForOneIteration) {
super.sendMessage('error', error, _merge({ url }));
}
} else {
super.sendMessage(
'error',
`${errorsForOneIteration} ${result[resultIndex].failureMessages}`,
_merge({ url })
);
}
}
// If we use scripts or multiple, use the URL from the tested page
// so that we can handle click on links etc
// see https://github.com/sitespeedio/sitespeed.io/issues/2260
// we could change the plugins but since they do not work with
// multiple/scripting lets do it like this for now
if (this.scriptOrMultiple) {
url = result[resultIndex].info.url;
group = parse(url).hostname;
url = result[resultIndex].info?.url;
if (url) {
group = parse(url).hostname;
}
}
let runIndex = 0;
for (let browserScriptsData of result[resultIndex].browserScripts) {
@ -597,14 +615,6 @@ export default class BrowsertimePlugin extends SitespeedioPlugin {
group
});
}
// Check for errors. Browsertime errors is an array of all iterations
// [[],[],[]] where one iteration can have multiple errors
for (let errorsForOneIteration of result[resultIndex].errors) {
for (let error of errorsForOneIteration) {
super.sendMessage('error', error, _merge({ url }));
}
}
}
break;
} catch (error) {