doc: fix asyncLocalStorage.run() description · nodejs/node@afc6ab2

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) {