Skip to content

Commit 6f77d1a

Browse files
elegantcodertargos
authored andcommitted
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: #40381 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
1 parent 93cecb4 commit 6f77d1a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/api/async_context.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ added:
223223
* `...args` {any}
224224

225225
Runs a function synchronously within a context and returns its
226-
return value. The store is not accessible outside of the callback function or
227-
the asynchronous operations created within the callback.
226+
return value. The store is not accessible outside of the callback function.
227+
The store is accessible to any asynchronous operations created within the
228+
callback.
228229

229230
The optional `args` are passed to the callback function.
230231

@@ -238,6 +239,9 @@ const store = { id: 2 };
238239
try {
239240
asyncLocalStorage.run(store, () => {
240241
asyncLocalStorage.getStore(); // Returns the store object
242+
setTimeout(() => {
243+
asyncLocalStorage.getStore(); // Returns the store object
244+
}, 200);
241245
throw new Error();
242246
});
243247
} catch (e) {

0 commit comments

Comments
 (0)