diff options
author | Darkripper214 <phakorn214@gmail.com> | 2021-04-01 17:06:48 +0300 |
---|---|---|
committer | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2021-04-03 21:09:02 +0300 |
commit | a44392d7dd83a999069c59b0d76aa88201e2c2d6 (patch) | |
tree | d192cd69bae1ba6b8369b6c46cde61e3f0ad7dba /doc/api/async_hooks.md | |
parent | a59b6a1bc6714c230339cea0c3a007e905b29191 (diff) |
doc: fix asyncLocalStorage.run() description
The description that store is not available
when asynchronous operation is created within
the callback is not accurate
Fixes: https://github.com/nodejs/node/issues/38022
PR-URL: https://github.com/nodejs/node/pull/38023
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Diffstat (limited to 'doc/api/async_hooks.md')
-rw-r--r-- | doc/api/async_hooks.md | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 83efca6a5c5..36aa464a142 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -1124,8 +1124,9 @@ added: * `...args` {any} Runs a function synchronously within a context and returns its -return value. The store is not accessible outside of the callback function or -the asynchronous operations created within the callback. +return value. The store is not accessible outside of the callback function. +The store is accessible to any asynchronous operations created within the +callback. The optional `args` are passed to the callback function. @@ -1139,6 +1140,9 @@ const store = { id: 2 }; try { asyncLocalStorage.run(store, () => { asyncLocalStorage.getStore(); // Returns the store object + setTimeout(() => { + asyncLocalStorage.getStore(); // Returns the store object + }, 200); throw new Error(); }); } catch (e) { |