AsyncLocalStorage

A Node.js feature that keeps a value available to all code running for one request, even across await and callbacks, without passing it as an argument.

In more detail

Middleware calls asyncLocalStorage.run(context, next), and any function later in that request can read the correlation ID, user or tenant from the store. Unlike a global variable, concurrent requests each see their own value.

Related terms

Taught in

References