-
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: convert gather-runner.js to async/await #5462
core: convert gather-runner.js to async/await #5462
Conversation
const pass = Promise.resolve() | ||
// Clear disk & memory cache if it's a perf run | ||
.then(_ => { | ||
if (isPerfRun) driver.cleanBrowserCaches(); |
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.
this code wasn't be awaited, but it looks like it should be. Same with beginTrace
down below.
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.
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)
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.
maybe https://palantir.github.io/tslint/rules/no-floating-promises/, which isn't perfect but would have caught this
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.
I think just using async/await makes these stand out a lot more. That lint rule might be more trouble than its worth.
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 cleanup thanks @JoelEinbinder! 💯
|
||
// Navigate. | ||
await GatherRunner.loadPage(driver, passContext); | ||
await log.log('statusEnd', status); |
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.
this one shouldn't need to be awaited
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.
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.
LGTM! Thanks for the cleanup
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
.