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

core: convert gather-runner.js to async/await #5462

Merged
merged 2 commits into from
Jun 11, 2018

Conversation

JoelEinbinder
Copy link
Contributor

I was reading through how this file worked, and decided to convert it to async/await as I did. Clears up some dastardly uses of array.reduce.

const pass = Promise.resolve()
// Clear disk & memory cache if it's a perf run
.then(_ => {
if (isPerfRun) driver.cleanBrowserCaches();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this code wasn't be awaited, but it looks like it should be. Same with beginTrace down below.

Copy link
Member

Choose a reason for hiding this comment

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

whoops :( Good catch.

I wonder if there's a lint rule that checks if promises like this are eventually awaited/resolved. Would be easier with type information with tslint, but seems like you could reason about it entirely locally (caller's responsibility if it's returned)

Copy link
Member

Choose a reason for hiding this comment

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

maybe https://palantir.github.io/tslint/rules/no-floating-promises/, which isn't perfect but would have caught this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think just using async/await makes these stand out a lot more. That lint rule might be more trouble than its worth.

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.

nice cleanup thanks @JoelEinbinder! 💯


// Navigate.
await GatherRunner.loadPage(driver, passContext);
await log.log('statusEnd', status);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this one shouldn't need to be awaited

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the cleanup

@patrickhulce patrickhulce merged commit f287859 into GoogleChrome:master Jun 11, 2018
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.

None yet

3 participants