AsyncLocalStorage
AsyncLocalStorage is a class in Node.js's async_hooks module that provides a way to associate data with the current asynchronous execution context and access that data from any point within the same chain of asynchronous calls. It is commonly used to implement per-request or per-operation context, such as correlation IDs or logging context, that must survive across asynchronous boundaries.
The API centers on an AsyncLocalStorage instance. You create one with new AsyncLocalStorage(), and you interact
Example usage in plain terms: const als = new AsyncLocalStorage(); als.run(new Map([['requestId', '123']]), () => { // within this chain const
Limitations include that AsyncLocalStorage does not automatically propagate across worker threads or separate processes, and some
---