Skip to content

Commit 49f1374

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 4318e70 commit 49f1374

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
@@ -955,6 +955,11 @@ chains. It allows storing data throughout the lifetime of a web request
955955
or any other asynchronous duration. It is similar to thread-local storage
956956
in other languages.
957957

958+
While you can create your own implementation on top of the `async_hooks` module,
959+
`AsyncLocalStorage` should be preferred as it is a performant and memory safe
960+
implementation that involves significant optimizations that are non-obvious to
961+
implement.
962+
958963
The following example uses `AsyncLocalStorage` to build a simple logger
959964
that assigns IDs to incoming HTTP requests and includes them in messages
960965
logged within each request.

0 commit comments

Comments
 (0)