Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/workers-runtime-apis-nodejs-asynclocalstorage-workflow-guide.mdDocumentation 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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