-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core: add top-level runtimeError #6014
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d5e4755
core: add top-level runtimeError
brendankenny 683a77c
use error code; wrap thrown errors in LR
brendankenny 76689df
pseudoLHR
brendankenny 91c171b
goldenLHR
brendankenny 8e228bd
add tests
brendankenny 09e5c20
unknownsss
brendankenny accc297
fix extension window export
brendankenny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ const background = require('./lighthouse-background'); | |
const ExtensionProtocol = require('../../../lighthouse-core/gather/connections/extension'); | ||
const log = require('lighthouse-logger'); | ||
const assetSaver = require('../../../lighthouse-core/lib/asset-saver.js'); | ||
const LHError = require('../../../lighthouse-core/lib/lh-error.js'); | ||
|
||
/** @type {Record<'mobile'|'desktop', LH.Config.Json>} */ | ||
const LR_PRESETS = { | ||
|
@@ -111,14 +112,29 @@ async function runLighthouseInLR(connection, url, flags, {lrDevice, categoryIDs, | |
config.settings.onlyCategories = categoryIDs; | ||
} | ||
|
||
const results = await lighthouse(url, flags, config, connection); | ||
if (!results) return; | ||
try { | ||
const results = await lighthouse(url, flags, config, connection); | ||
if (!results) return; | ||
|
||
if (logAssets) { | ||
await assetSaver.logAssets(results.artifacts, results.lhr.audits); | ||
} | ||
if (logAssets) { | ||
await assetSaver.logAssets(results.artifacts, results.lhr.audits); | ||
} | ||
return results.report; | ||
} catch (err) { | ||
// If an error ruined the entire lighthouse run, attempt to return a meaningful error. | ||
if (!(err instanceof LHError) || !err.lhrRuntimeError) { | ||
throw err; | ||
} | ||
|
||
const runtimeError = { | ||
code: err.code, | ||
message: err.friendlyMessage ? | ||
`${err.friendlyMessage} (${err.message})` : | ||
err.message, | ||
}; | ||
|
||
return results.report; | ||
return JSON.stringify(runtimeError, null, 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking we're returning a psuedo LHR so one more level on top of this: return JSON.stringify({runtimeError}, null, 2); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah I missed that. |
||
} | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In this situation I think we should not throw but instead return an "UNKNOWN_ERROR" i guess.
tbh i dont know what throwing does in this context. my guess is its not caught and triggers a timeout?
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.
well it would throw and be up to the caller to deal with, but we can do
UNKNOWN_ERROR
instead :)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.
done