Asynchronous context tracking | Node.js v26.4.0 Documentation
These classes are used to associate state and propagate it throughout callbacks and promise chains. They allow storing data throughout the lifetime of a web request or any other asynchronous duration. It is similar to thread-local storage in other languages. The AsyncLocalStorage and AsyncResource classes are part of the node:async_hooks module: This class creates stores that stay coherent through asynchronous operations. While you can create your own implementation on top of the node:async_hooks module, AsyncLocalStorage should be preferred as it is a performant and memory safe implementation that involves significant optimizations that are non-obvious to implement. The following example uses AsyncLocalStorage to build a simple logger that assigns IDs to incoming HTTP requests and includes them in messages logged within each request. Each instance of AsyncLocalStorage maintains an independent storage context. Multiple instances can safely exist simultaneously without risk of interferi
Asynchronous context tracking | Node.js v26.5.0 Documentation Skip to content Node.js About this documentation Usage and example Assertion testing Asynchronous context tracking Async hooks Buffer C++ addons C/C++ addons with Node-API C++ embedder API Child processes Cluster Command-line options Console Crypto Debugger Deprecated APIs Diagnostics Channel DNS Domain Environment Variables Errors Events File system FFI Globals HTTP HTTP/2 HTTPS Inspector Internationalization Iterable Streams API Modules: CommonJS modules Modules: ECMAScript modules Modules: node:module API Modules: Packages Module
related reading
- Microtasks and event looptr.javascript.info
- TypeScript Structured Concurrencythecandidstartup.org
- Notes on structured concurrency, or: Go statement considered harmful - njs blogvorpus.org
- What the heck is the event loop anyway? | Philip Roberts | JSConf EUyoutube.com
- Reading 15: Promisesweb.mit.edu
- The Event Loop and Callback Hell - Wes Boswesbos.com
- (Quite) A Few Words About Asyncyoric.github.io
- What Async Promised and What it Delivered — Causalitycausality.blog
- Show HN: RemoteStorage – sync localStorage across devices and browsersnews.ycombinator.com
- 100 Node.js Interview Questions With Answers (2026)simplilearn.com
- How Python Asyncio Works: Recreating it from Scratchjacobpadilla.com
- Introduction - Asynchronous Programming in Rustrust-lang.github.io