diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 24ad177feff032..1a8debe8451d0b 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -955,6 +955,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.