Skip to content

Commit afc6ab2

Browse files
PhakornKiongMylesBorins
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 3175559 commit afc6ab2

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
@@ -1114,8 +1114,9 @@ added:
11141114
* `...args` {any}
11151115

11161116
Runs a function synchronously within a context and returns its
1117-
return value. The store is not accessible outside of the callback function or
1118-
the asynchronous operations created within the callback.
1117+
return value. The store is not accessible outside of the callback function.
1118+
The store is accessible to any asynchronous operations created within the
1119+
callback.
11191120

11201121
The optional `args` are passed to the callback function.
11211122

@@ -1129,6 +1130,9 @@ const store = { id: 2 };
11291130
try {
11301131
asyncLocalStorage.run(store, () => {
11311132
asyncLocalStorage.getStore(); // Returns the store object
1133+
setTimeout(() => {
1134+
asyncLocalStorage.getStore(); // Returns the store object
1135+
}, 200);
11321136
throw new Error();
11331137
});
11341138
} catch (e) {

0 commit comments

Comments
 (0)