-
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
cli: write report in runLighthouse before quitting Chrome #7339
Conversation
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.
WFM
*/ | ||
function showRuntimeError(err) { | ||
console.error('Runtime error encountered:', err.friendlyMessage || err.message); | ||
if (err.stack) { | ||
console.error(err.stack); | ||
} | ||
process.exit(_RUNTIME_ERROR_CODE); |
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.
what's the benefit of these return process.exit
changes?
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.
what's the benefit of these
return process.exit
changes?
purely tsc, you have to return it to take advantage of the @return {never}
chain
lighthouse-cli/run.js
Outdated
if (!launchedChrome) return; | ||
|
||
try { | ||
await launchedChrome.kill(); |
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.
should we time this out?
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.
should we time this out?
probably, but the Chrome child process still keeps the main process going, so it just prints a Couldn't quit Chrome process. Timed out.
error message but still sits there spinning. Is that better?
We could also process.exit(1)
in that case, but assuming we want to always exit in that case seems like it might be excessive?
return Promise.resolve({}); | ||
|
||
await potentiallyKillChrome(launchedChrome); | ||
process.removeListener('unhandledRejection', handleTheUnhandled); |
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.
should this be removed in catch
too?
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.
should this be removed in
catch
too?
handleError
always ends with a process.exit()
, so it doesn't matter in the catch
case. If we moved handleError
to bin.js
, though, we could put both potentiallyKillChrome
and removing the listener to a finally
block, which would be kind of nice.
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.
oh right 👍
while we wait for the fix for https://crbug.com/936272 and/or in chrome-launcher, this change at least writes the report to disk before waiting for Chrome to close.
Also removes the
unhandledRejection
listener when done (fixing theMaxListenersExceededWarning
for @hoten) and convertsrunLighthouse
to use async/await, as the ancient promise business in there was inscrutable. I think there's still more to improve here, both bikeshedding and file organization (e.g.handleError
should maybe be inbin.js
, not in here); happy for more ideas or leaving all that for yet another day.