Skip to content

Commit da010ae

Browse files
committed
docs: upfront recommend against using the no-return-await rule
1 parent e86edee commit da010ae

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ further_reading:
77
- https://jakearchibald.com/2017/await-vs-return-vs-return-await/
88
---
99

10+
It is NOT recommended to use the `no-return-await` rule anymore because:
11+
12+
- `return await` on a promise will not result in an extra microtask.
13+
- `return await` yields a better stack trace for debugging.
14+
15+
The following documentation is kept for historical context, and is not necessarily accurate anymore.
16+
1017
The original intent of this rule was to discourage the use of `return await`, to avoid an extra microtask. However, due to the fact that JavaScript now handles native `Promise`s differently, there is no longer an extra microtask. More technical information can be found in [this V8 blog entry](https://v8.dev/blog/fast-async).
1118

1219
Using `return await` inside an `async function` keeps the current function in the call stack until the Promise that is being awaited has resolved, at the cost of an extra microtask before resolving the outer Promise. `return await` can also be used in a try/catch statement to catch errors from another function that returns a Promise.

0 commit comments

Comments
 (0)