Skip to content

Commit a44392d

Browse files
PhakornKiongaduh95
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 Fixes: #38022 PR-URL: #38023 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent a59b6a1 commit a44392d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

doc/api/async_hooks.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,9 @@ added:
11241124
* `...args` {any}
11251125

11261126
Runs a function synchronously within a context and returns its
1127-
return value. The store is not accessible outside of the callback function or
1128-
the asynchronous operations created within the callback.
1127+
return value. The store is not accessible outside of the callback function.
1128+
The store is accessible to any asynchronous operations created within the
1129+
callback.
11291130

11301131
The optional `args` are passed to the callback function.
11311132

@@ -1139,6 +1140,9 @@ const store = { id: 2 };
11391140
try {
11401141
asyncLocalStorage.run(store, () => {
11411142
asyncLocalStorage.getStore(); // Returns the store object
1143+
setTimeout(() => {
1144+
asyncLocalStorage.getStore(); // Returns the store object
1145+
}, 200);
11421146
throw new Error();
11431147
});
11441148
} catch (e) {

0 commit comments

Comments
 (0)