Skip to content
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

Merged
merged 3 commits into from
Mar 1, 2019

Conversation

brendankenny
Copy link
Member

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 the MaxListenersExceededWarning 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 in bin.js, not in here); happy for more ideas or leaving all that for yet another day.

Copy link
Collaborator

@patrickhulce patrickhulce left a 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);
Copy link
Collaborator

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?

Copy link
Member Author

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

if (!launchedChrome) return;

try {
await launchedChrome.kill();
Copy link
Collaborator

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?

Copy link
Member Author

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);
Copy link
Collaborator

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?

Copy link
Member Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right 👍

@brendankenny brendankenny changed the title cli(runLighthouse): write report before quitting Chrome cli: write report in runLighthouse before quitting Chrome Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants