Skip to content

Commit c79688f

Browse files
brillouttargos
authored andcommitted
doc: improve AsyncLocalStorage introduction
PR-URL: #36946 Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Andrey Pechkurov <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 81e9acf commit c79688f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/api/async_hooks.md

+5
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,11 @@ chains. It allows storing data throughout the lifetime of a web request
963963
or any other asynchronous duration. It is similar to thread-local storage
964964
in other languages.
965965

966+
While you can create your own implementation on top of the `async_hooks` module,
967+
`AsyncLocalStorage` should be preferred as it is a performant and memory safe
968+
implementation that involves significant optimizations that are non-obvious to
969+
implement.
970+
966971
The following example uses `AsyncLocalStorage` to build a simple logger
967972
that assigns IDs to incoming HTTP requests and includes them in messages
968973
logged within each request.

0 commit comments

Comments
 (0)