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

[cleanup] remove unexpected awaits #2806

Merged
merged 3 commits into from
Nov 11, 2020
Merged

[cleanup] remove unexpected awaits #2806

merged 3 commits into from
Nov 11, 2020

Conversation

bkendall
Copy link
Contributor

@bkendall bkendall commented Nov 11, 2020

Description

Removing the await-thenable warning and fixing all the errors.

Scenarios Tested

  • give a few more commands some sanity testing

@google-cla google-cla bot added the cla: yes Manual indication that this has passed CLA. label Nov 11, 2020
@bkendall bkendall changed the title remove unexpected awaits [cleanup] remove unexpected awaits Nov 11, 2020
@bkendall bkendall marked this pull request as ready for review November 11, 2020 01:05
@@ -424,7 +424,7 @@ export class FunctionsEmulator implements EmulatorInstance {
added = await this.addPubsubTrigger(this.args.projectId, definition);
break;
case Constants.SERVICE_AUTH:
added = await this.addAuthTrigger(this.args.projectId, definition);
added = this.addAuthTrigger(this.args.projectId, definition);
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is a bit suspicious to me. I guess because auth is in-process it can be added synchronously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup - it's a sync function, not async, so no need to await

Copy link
Contributor

@samtstern samtstern left a comment

Choose a reason for hiding this comment

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

Two small comments

@@ -25,7 +25,7 @@ export interface FunctionProxyRewrite {
export default function(
options: FunctionsProxyOptions
): (r: FunctionProxyRewrite) => Promise<RequestHandler> {
return async (rewrite: FunctionProxyRewrite) => {
return (rewrite: FunctionProxyRewrite) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: You may want to wrap the whole function body around new Promise to keep the behavior the same. Before, any errors in the function body will be returned as a rejected Promise. Now it just synchronously throws (which can be really bad), unless you wrap everything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I'll wrap it. Thanks.

Copy link
Member

@yuchenshi yuchenshi left a comment

Choose a reason for hiding this comment

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

LGTM (with nit above)

@bkendall bkendall merged commit f6ffc3f into master Nov 11, 2020
@bkendall bkendall deleted the bk-await-thenable branch November 11, 2020 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants