Skip to content

Commit 63d978c

Browse files
brilloutjasnell
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 7394311 commit 63d978c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/api/async_hooks.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,11 @@ chains. It allows storing data throughout the lifetime of a web request
973973
or any other asynchronous duration. It is similar to thread-local storage
974974
in other languages.
975975

976+
While you can create your own implementation on top of the `async_hooks` module,
977+
`AsyncLocalStorage` should be preferred as it is a performant and memory safe
978+
implementation that involves significant optimizations that are non-obvious to
979+
implement.
980+
976981
The following example uses `AsyncLocalStorage` to build a simple logger
977982
that assigns IDs to incoming HTTP requests and includes them in messages
978983
logged within each request.

0 commit comments

Comments
 (0)