diff options
| author | Constantine Kim <elegantcoder@gmail.com> | 2021-10-09 01:58:09 +0900 |
|---|---|---|
| committer | Node.js GitHub Bot <github-bot@iojs.org> | 2021-10-11 06:59:03 +0000 |
| commit | ca6adcf37e6f4003b3d879b96e4fef320af14c76 (patch) | |
| tree | 67a523bae97d9fad353e7d5266077e4fce7d790a /doc/api/async_context.md | |
| parent | 0cc37209fa0c4dc065bd1e2ee6f5aa9e0c397376 (diff) | |
| download | node-new-ca6adcf37e6f4003b3d879b96e4fef320af14c76.tar.gz | |
doc: fix asyncLocalStorage.run() description
The description that store is not available
when asynchronous operation is created within
the callback is not accurate
PR-URL: https://github.com/nodejs/node/pull/40381
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Diffstat (limited to 'doc/api/async_context.md')
| -rw-r--r-- | doc/api/async_context.md | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/doc/api/async_context.md b/doc/api/async_context.md index 7c949f6585..78cfc08461 100644 --- a/doc/api/async_context.md +++ b/doc/api/async_context.md @@ -223,8 +223,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. @@ -238,6 +239,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) { |
