Open this example in the interactive library
Source code
import {
AsyncLocalStorage,
AsyncResource,
executionAsyncId,
} from "node:async_hooks";
const context = new AsyncLocalStorage();
console.log(
await context.run("request", async () => {
await Promise.resolve();
return context.getStore();
}),
);
Sample output
request
