diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 4a8a225c576fdb..5f1d578beeb351 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -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, +`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.