You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a section in the documentation regarding AsyncLocalStorage.run that states:
This methods runs a function synchronously within a context and return its return value. The store is not accessible outside of the callback function or the asynchronous operations created within the callback.
As far as I can tell this is not true, for example:
const{AsyncLocalStorage}=require('async_hooks');conststorage=newAsyncLocalStorage();storage.run('anything',()=>{setTimeout(()=>{console.log(storage.getStore());// prints "anything"},10);});
I'd consider setTimeout callback to be an asynchronous operation created within the callback and the store is accessible there.
I would like to work on this issue and
submit a pull request
The text was updated successfully, but these errors were encountered:
Sorry, I just now realized that I've most likely misinterpreted the docs: I thought they stated that store is not accessible in the asynchronous operations created within the callback, but now I see that it's the opposite, which is consistent with the behavior. Carry on 😅
I misread that too. Even after reading this report, it still took about a dozen readings before I understood. For any future reader of this ticket, what it's really saying is The store is not accessible outside of the callback function or **outside** the asynchronous operations created within the callback
📗 API Reference Docs Problem
Affected URL(s):
Description
There's a section in the documentation regarding
AsyncLocalStorage.run
that states:As far as I can tell this is not true, for example:
I'd consider
setTimeout
callback to be an asynchronous operation created within the callback and the store is accessible there.submit a pull request
The text was updated successfully, but these errors were encountered: