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
Explore this link on the map →related reading
- TypeScript Structured Concurrencythecandidstartup.org
- Reading 15: Promisesweb.mit.edu
- Microtasks and event looptr.javascript.info
- What Async Promised and What it Delivered — Causalitycausality.blog
- Reading 16: Mutual Exclusionweb.mit.edu
- Context (ctx) · Cloudflare Workers docsdevelopers.cloudflare.com
- async/await on embedded Rust - Ferrous Systemsferrous-systems.com
- Let futures be futureswithout.boats
- Markov's Salonmarkovs-salon.vercel.app
- Who Runs Your Rust Future? Hands-On Intro to Async Rust | AIBodhaibodh.com
- The Event Loop and Callback Hell - Wes Boswesbos.com
- API Reference: Edge Runtime | Next.jsnextjs.org