Skip to content

Commit dbc3af8

Browse files
authored
feat: surface Lighthouse runtime errors (#67)
1 parent f0c32c6 commit dbc3af8

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/localLighthouse.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export const localLighthouse = async ({
122122
localReport,
123123
report,
124124
emulatedFormFactor,
125+
runtimeError: get(result, 'runtimeError.message'),
125126
scores
126127
};
127128
};

src/logResults.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ export default ({ isGitHubAction, isLocalAudit, isOrb, results }) => {
4444
Object.values(result.scores)
4545
];
4646
console.log('\n');
47-
console.log(table(tableData, tableConfig));
47+
if (result.runtimeError) {
48+
console.log(`Lighthouse runtime error: ${result.runtimeError}`);
49+
} else {
50+
console.log(table(tableData, tableConfig));
51+
}
4852
console.log('\n');
4953
});
5054

src/postPrComment.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import LighthouseCheckError from './LighthouseCheckError';
55
import { ERROR_UNEXPECTED_RESPONSE } from './errorCodes';
66
import { NAME } from './constants';
77

8-
const getBadge = ({ title, score }) =>
8+
const getBadge = ({ title, score = 0 }) =>
99
`![](https://img.shields.io/badge/${title}-${score}-${getLighthouseScoreColor(
1010
{
1111
isHex: false,
@@ -43,6 +43,11 @@ export default async ({
4343
});
4444
});
4545

46+
// error
47+
if (result.runtimeError) {
48+
markdown += `**Lighthouse runtime error**: ${result.runtimeError}\n\n`;
49+
}
50+
4651
// table header
4752
markdown += `\n| Device ${!result.report ? '' : `| Report `}| URL |\n`;
4853
markdown += `|--${!result.report ? '' : `|--`}|--|\n`;

src/slackNotify.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export default async ({
5454
footer
5555
})
5656
},
57+
...(result.runtimeError && {
58+
color: '#f74531',
59+
text: `*Lighthouse runtime error*: ${result.runtimeError}`,
60+
short: true
61+
}),
5762
...Object.keys(result.scores).map(current => ({
5863
color: getLighthouseScoreColor({
5964
isHex: true,

0 commit comments

Comments
 (0)