Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: improve AsyncLocalStorage introduction #36946

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/api/async_hooks.md
Expand Up @@ -973,6 +973,11 @@ chains. It allows storing data throughout the lifetime of a web request
or any other asynchronous duration. It is similar to thread-local storage
in other languages.

While you can create your own implementation on top of the `async_hooks` module,
Qard marked this conversation as resolved.
Show resolved Hide resolved
`AsyncLocalStorage` should be preferred as it is a performant and memory safe
implementation that involves significant optimizations that are non-obvious to
implement.

The following example uses `AsyncLocalStorage` to build a simple logger
that assigns IDs to incoming HTTP requests and includes them in messages
logged within each request.
Expand Down