Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRomuald Brillout <github@brillout.com>2021-01-15 18:38:13 +0300
committerJames M Snell <jasnell@gmail.com>2021-01-25 19:46:04 +0300
commit63d978c5c14a54bb8546c5aa7a8fd8c94a8744c2 (patch)
treeaa57dd47cee5dc8b4a640c488d1153549b979f69 /doc/api/async_hooks.md
parent7394311a2eba15270c34835da31973e1e5ab02db (diff)
doc: improve AsyncLocalStorage introduction
PR-URL: https://github.com/nodejs/node/pull/36946 Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc/api/async_hooks.md')
-rw-r--r--doc/api/async_hooks.md5
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md
index 4a8a225c576..5f1d578beeb 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.