Conversation
Without await, this will never actually catch the error in the try/catch block, but return the (rejected) promise.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
0x-cosmos
left a comment
There was a problem hiding this comment.
LGTM, and this would have saved me 5 minutes of debugging.
| export async function signOut() { | ||
| try { | ||
| return auth.signOut(); | ||
| await auth.signOut(); |
There was a problem hiding this comment.
In original code, we were returning the result "return auth.signOut();"
should we do instead "return await auth.signOut();" ? just for consistency of return value.
There was a problem hiding this comment.
We could, but auth.signOut() returns Promise<void>, so noone should be using the return value anyway.
Additionally the signIn function (signInWithGoogle()) also does not return the value, but simply awaits it.
One might even argue that simply awaiting without returning is more explicit about the intent of this not returning anything.
But ultimately this is a question of taste, so if you like, I can change it...
Without await, this will never actually catch the error in the try/catch block, but return the (rejected) promise.