diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index a353ef3b7b9f8f..c74c74d932fbb5 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -963,6 +963,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, +`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.