Skip to content

Commit ac59022

Browse files
PhakornKiongtargos
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 <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 8590720 commit ac59022

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

doc/api/async_hooks.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1096,8 +1096,9 @@ added: v13.10.0
10961096
* `...args` {any}
10971097

10981098
Runs a function synchronously within a context and returns its
1099-
return value. The store is not accessible outside of the callback function or
1100-
the asynchronous operations created within the callback.
1099+
return value. The store is not accessible outside of the callback function.
1100+
The store is accessible to any asynchronous operations created within the
1101+
callback.
11011102

11021103
The optional `args` are passed to the callback function.
11031104

@@ -1111,6 +1112,9 @@ const store = { id: 2 };
11111112
try {
11121113
asyncLocalStorage.run(store, () => {
11131114
asyncLocalStorage.getStore(); // Returns the store object
1115+
setTimeout(() => {
1116+
asyncLocalStorage.getStore(); // Returns the store object
1117+
}, 200);
11141118
throw new Error();
11151119
});
11161120
} catch (e) {

0 commit comments

Comments
 (0)