cloudflare · Cloudflare Workers Docs
Workers AsyncLocalStorage
Implementation of the Node.js AsyncLocalStorage API in Cloudflare Workers to maintain in-memory context across asynchronous operations using the nodejs_compat flag.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Workers AsyncLocalStorage
Implementation of the Node.js AsyncLocalStorage API in Cloudflare Workers to maintain in-memory context across asynchronous operations using the nodejs_compat flag.
When To Use
Use when you need to persist and access stateful context, such as request IDs or user sessions, across multiple asynchronous function calls without passing them explicitly through every argument.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-runtime-apis-nodejs-asynclocalstorage-workflow-guide.md | Documentation detailing the usage, constructor, and methods of the AsyncLocalStorage API within Cloudflare Workers. | Questions about documentation detailing the usage, constructor, and methods of the AsyncLocalStorage API within Cloudflare Workers. |
examples/workers-runtime-apis-nodejs-asynclocalstorage-cloudflare-workers-asynclo.text | A JavaScript code example demonstrating how to use the AsyncLocalStorage class from the node:async_hooks module within a Cloudflare Worker. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the AsyncLocalStorage class from the node:asynchooks module within... |
examples/workers-runtime-apis-nodejs-asynclocalstorage-cloudflare-workers-asynclo-2.text | A JavaScript code example demonstrating how to use AsyncLocalStorage to persist state across asynchronous execution contexts in a Cloudflare Worker. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use AsyncLocalStorage to persist state across asynchronous execution c... |
examples/workers-runtime-apis-nodejs-asynclocalstorage-cloudflare-workers-asynclo-3.text | A JavaScript code example demonstrating nested AsyncLocalStorage store management within a Cloudflare Workers fetch handler. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating nested AsyncLocalStorage store management within a Cloudflare Workers fetch h... |
examples/workers-runtime-apis-nodejs-asynclocalstorage-cloudflare-workers-asynclo-4.text | A JavaScript code example demonstrating how AsyncLocalStorage behaves when an unhandled rejection occurs within a Cloudflare Worker. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how AsyncLocalStorage behaves when an unhandled rejection occurs within a Clo... |
examples/workers-runtime-apis-nodejs-asynclocalstorage-cloudflare-workers-asynclo-5.text | A JavaScript code example demonstrating how to use the AsyncLocalStorage class from the node:async_hooks module within a Cloudflare Worker. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the AsyncLocalStorage class from the node:asynchooks module within... |
examples/workers-runtime-apis-nodejs-asynclocalstorage-cloudflare-workers-asynclo-6.text | A JavaScript code example demonstrating how to use AsyncLocalStorage to persist state across asynchronous execution contexts in Cloudflare Workers. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use AsyncLocalStorage to persist state across asynchronous execution c... |
examples/workers-runtime-apis-nodejs-asynclocalstorage-cloudflare-workers-asynclo-7.text | A JavaScript code example demonstrating how to use AsyncLocalStorage and AsyncResource within a Cloudflare Workers environment to manage asynchronous context. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use AsyncLocalStorage and AsyncResource within a Cloudflare Workers en... |
What This Skill Covers
- To enable built-in Node.js APIs and polyfills, add the nodejs\compat compatibility flag to your Wrangler configuration file. This also enables nodejs\compat...
- Main sections:
Background,Constructor,Methods,Static Methods,Examples.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.cloudflare.com/workers/runtime-apis/nodejs/asynclocalstorage
