Are there performance concerns with `return await`?
Solution 1:
No, there isn't any performance problem. It's just an unnecessary extra operation. It might take a bit longer to execute, but should be hardly noticeable. It's akin to return x+0
instead of return x
for an integer x
. Or rather, exactly equivalent to the pointless .then(x => x)
.
It doesn't do actual harm, but I'd consider it bad style and a sign that the author does not fully comprehend promises and async
/await
.
However, there's one case where it make an important difference:
try {
…
return await …;
} …
await
does throw on rejections, and in any case awaits the promise resolution before catch
or finally
handlers are executed. A plain return
would have ignored that.