Skip to content

Commit bea4c4f

Browse files
authored
Update no-return-await.md
1 parent d71bf2e commit bea4c4f

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

docs/src/rules/no-return-await.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,9 @@ It is NOT recommended to use the `no-return-await` rule anymore because:
1414

1515
Historical context: When promises were first introduced, calling `return await` introduced an additional microtask, one for the `await` and one for the return value of the async function. Each extra microtask delays the computation of a result and so this rule was added to help avoid this performance trap. Later, [V8 changed the way](https://v8.dev/blog/fast-async) `return await` worked so it would create a single microtask, which means this rule is no longer necessary.
1616

17-
***
18-
19-
This rule warns on any usage of `return await`.
20-
21-
Using `return await` inside an `async function` keeps the current function in the call stack until the Promise that is being awaited has resolved. `return await` can also be used in a try/catch statement to catch errors from another function that returns a Promise.
22-
23-
You can avoid the extra microtask by not awaiting the return value, with the trade off of the function no longer being a part of the stack trace if an error is thrown asynchronously from the Promise being returned. This can make debugging more difficult.
24-
2517
## Rule Details
2618

27-
This rule aims to prevent a likely common performance hazard due to a lack of understanding of the semantics of `async function`.
19+
This rule warns on any usage of `return await`.
2820

2921
Examples of **incorrect** code for this rule:
3022

@@ -74,8 +66,4 @@ async function foo4() {
7466

7567
## When Not To Use It
7668

77-
There are a few reasons you might want to turn this rule off:
78-
79-
* If you want to use `await` to denote a value that is a thenable
80-
* If you do not want the performance benefit of avoiding `return await`
81-
* If you want the functions to show up in stack traces (useful for debugging purposes)
69+
You should not use this rule. There is no reason to avoid `return await`.

0 commit comments

Comments
 (0)