Using dotnet-sonarscanner 5.2.1
This follows up on "await" should not be used redundantly with a different argument. And that is that this suggestion affects generated stack traces, and if anything, I would prefer if the rule suggested it the other way around.
Take for example the following:
async function throwing() {
await await new Promise(accept => setTimeout(accept, 0));
throw new Error("test");
}
async function supposedlyBad() {
return await throwing();
}
async function supposedlyGood() {
return throwing();
}
When calling supposedlyBad
, this is the stacktrace:
Uncaught (in promise) Error: test
at throwing (<anonymous>:3:9)
at async supposedlyBad (<anonymous>:6:10)
However for supposedlyGood
, you get this:
Uncaught (in promise) Error: test
at throwing (<anonymous>:3:9)
Suddenly you’re missing the function, as it’s no longer part of the awaited execution flow. Similarly, a breakpoint will skip over it. Is this a known and intended effect of the rule?