-
Notifications
You must be signed in to change notification settings - Fork 33
Surface runtime errors in Deploy Log and Deploy Summary #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
return actual < expected; | ||
}; | ||
|
||
const getError = (id, expected, categories, audits) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unchanged, just moved and tested
const { minify } = require('html-minifier'); | ||
const { makeReplacements } = require('./replacements'); | ||
|
||
const belowThreshold = (id, expected, categories) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function unchanged, just moved and tested
return { message: categoryError, details: categoryAudits }; | ||
}; | ||
|
||
const formatShortSummary = (categories) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split out from following function
}; | ||
|
||
const formatResults = ({ results, thresholds }) => { | ||
const runtimeError = results.lhr.runtimeError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line
...(thresholds[id] ? { threshold: thresholds[id] } : {}), | ||
})); | ||
|
||
const shortSummary = formatShortSummary(categories); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now uses formatShortSummary
(previous function in file) as a standalone function rather than doing in-place
minifyJS: true, | ||
}); | ||
|
||
return { summary, shortSummary, details, report, errors, runtimeError }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds runtimeError
to the end
}, {}); | ||
} | ||
|
||
if (runtimeError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Send the runtimeError
off to the Deploy Summary, instead of shortSumary
(which is undefined)
@@ -289,17 +240,23 @@ module.exports = { | |||
output_path, | |||
settings, | |||
}); | |||
if (summary) { | |||
|
|||
if (summary && !runtimeError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't show the summary when there's an error
|
||
const fullPath = [serveDir, path].join('/'); | ||
if (report) { | ||
const size = Buffer.byteLength(JSON.stringify(report)); | ||
console.log( | ||
`Report collected: audited_uri: '${chalk.magenta( | ||
url || fullPath, | ||
)}', html_report_size: ${chalk.magenta(size / 1024)} KiB`, | ||
)}', html_report_size: ${chalk.magenta( | ||
+(size / 1024).toFixed(2), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random bonus fix to round the file size to maximum 2 decimal places
@@ -54,9 +54,6 @@ const runLighthouse = async (browserPath, url, settings) => { | |||
}, | |||
settings, | |||
); | |||
if (results.lhr.runtimeError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to be removed to allow the error to be handle more gracefully elsewhere
return actual < expected; | ||
}; | ||
|
||
const getError = (id, expected, categories, audits) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function unchanged, just moved and tested
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This is going to make things much clearer ✨
const persistResults = async ({ report, path }) => { | ||
await fs.mkdir(dirname(path), { recursive: true }); | ||
await fs.writeFile(path, report); | ||
}; | ||
|
||
const getUtils = ({ utils }) => { | ||
// This function checks to see if we're running within the Netlify Build system, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the additional comments 😍
👷 Deploy Preview for plugin-lighthouse processing.
|
CI is failing on the coloured strings. I'll try some simpler partial text matching instead |
Managed to get there eventually… tests are passing on CI now that ANSI codes are stripped |
Closes https://github.com/netlify/netlify-plugin-lighthouse/issues/503
Closes https://github.com/netlify/netlify-plugin-lighthouse/issues/494
Closes https://github.com/netlify/netlify-plugin-lighthouse/issues/415
Likely solves others with mention of
undefined
results. We should do an issue sweep on ThursEnsures any runtime errors reported by Lighthouse are passes around alongside the rest of the data. This is then surfaced in the Deploy Log (directly after the failing run) and as an item in the Deploy summary.
This PR also moves some "data formatting" functions to a standalone file and adds tests. In my first attempt, these were being more heavily modified to deal with the runtimeError, but I ended up undoing that. It seemed a shame to put the functions back, so I've kept them. I've marked the exact sections which changes for easier reviewing.
For Netlifiers, check out https://app.netlify.com/sites/with-lighthouse-plugin/deploys/6359368d902825000811cdfa#L695
Deploy Summary

Three runs, one of which failed:
We use the error string provided by Lighthouse. I considered writing a few shorter versions to go in the Deploy Summary but seeing the list of possible variations made me think again!
Deploy Log

We're showing the full error here, not just the message part. This should help add some google-ability using the
code
incase the message text changes in future.