In short: Sonar was wrong, you never skip that await in return await asyncFn();
.
There used to be a performance benefit argument, there also used to be people saying it is the same anyway so why don't we spare those 6 keystrokes?
But towards the end of 2022 the industry is slowly arriving at an understanding that this rule was a bad idea.
The performance claims were shown to be false:
Are there performance concerns with `return await`?
And also it turns out it is not the same. By skipping await
an enclosing try-catch will not catch the errors and an enclosing try-finally
will not wait for the promise, so the finally
block will run sooner than expected.
It is planned to remove the rule from the default ruleset:
https://community.sonarsource.com/t/await-should-not-be-used-redundantly/29074/8