Request Context Without Prop Drilling: AsyncLocalStorage in Node.js

Every non-trivial Node.js service eventually hits the same wall: you need a trace ID, tenant ID, or authenticated user available six layers deep in your call stack, inside a utility that has no business knowing about HTTP requests. The instinctive fix is to add a ctx parameter to every function between the request handler and that utility. Three months later, the ctx type has grown to fifteen fields, half your function signatures start with it, and adding a new context value means touching a dozen files.

AsyncLocalStorage — stable since Node 16, available since Node 12 behind a flag — solves this cleanly. It's the Node.js equivalent of thread-local storage: a value bound to an asynchronous execution context that flows automatically through await, setTimeout, Promise.then, and event emitter callbacks without any explicit parameter passing.