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

Use await instead of promises #1495

Closed
wants to merge 1 commit into from
Closed

Use await instead of promises #1495

wants to merge 1 commit into from

Conversation

fhinkel
Copy link
Contributor

@fhinkel fhinkel commented Sep 25, 2019

Drive-by fix: Run linter for template strings.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 25, 2019
@fhinkel fhinkel added the kokoro:run Add this label to force Kokoro to re-run the tests. label Sep 25, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Sep 25, 2019
@ace-n
Copy link
Contributor

ace-n commented Sep 25, 2019

This may have been obviated by #1489 🙂

@fhinkel fhinkel added the kokoro:run Add this label to force Kokoro to re-run the tests. label Sep 25, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Sep 25, 2019
@grant grant removed their request for review September 25, 2019 23:23
@fhinkel fhinkel added the kokoro:run Add this label to force Kokoro to re-run the tests. label Sep 25, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Sep 25, 2019
@fhinkel
Copy link
Contributor Author

fhinkel commented Sep 25, 2019

Haha, yes, most is obviated. But a few last changes are left.

Copy link
Contributor

@gguuss gguuss left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@ace-n ace-n left a comment

Choose a reason for hiding this comment

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

// Return a formatted message
resolve(formatSlackMessage(query, response));
const makeSearchRequest = async query => {
await kgsearch.entities.search(
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Do we know if this actually returns a promise? (either via running it ourselves, or reviewing Slack's docs)
  2. If so, we should get rid of the callback below. 🙂

} catch (err) {
console.error(err);
res.status(err.code || 500).send(err);
return Promise.reject(err);
throw err;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit (perhaps better addressed in a different PR): redundant?

`SingerId: ${row.SingerId}, ` +
`AlbumId: ${row.AlbumId}, ` +
`AlbumTitle: ${row.AlbumTitle}\n`
`SingerId: ${row.SingerId}, AlbumId: ${row.AlbumId}, AlbumTitle: ${row.AlbumTitle}\n`
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe @grant was 👎on this.

pushNotification(
data['deviceID'],
doc.data().accessToken,
doc.data().expireTime
);
return doc.data();
await doc.data();
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems confusing - why are we using doc.data() presumably before we've awaited it? (If we know this case definitely won't happen, we should at least leave a comment explaining that.)

cc @santhoshvaddi

Copy link
Contributor

Choose a reason for hiding this comment

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

After push notification we just want to return from the function. The client will receive the token in the form of push notification. I don't think await is required here.

functions/tokenservice/functions/index.js Show resolved Hide resolved
functions/tokenservice/functions/index.js Show resolved Hide resolved
Copy link
Contributor

@kurtisvg kurtisvg left a comment

Choose a reason for hiding this comment

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

LGTM for /cloud-sql/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants