Prompt Buddy logoPrompt Buddy

cloudflare · Cloudflare Workers Docs

Workers Lifecycle

Explains how to manage memory and resource lifecycles for RPC stubs in Cloudflare Workers, specifically using the JavaScript using declaration to ensure remote objects are properly disposed of and garbage collected.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Workers Lifecycle

Explains how to manage memory and resource lifecycles for RPC stubs in Cloudflare Workers, specifically using the JavaScript using declaration to ensure remote objects are properly disposed of and garbage collected.

When To Use

Use when you need to prevent memory leaks by ensuring RPC stubs are explicitly disposed of to allow the server-side isolate to garbage collect remote objects.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/workers-runtime-apis-rpc-lifecycle-workflow-guide.mdDocumentation explaining memory management, lifetimes, and explicit resource disposal when using RPC via service bindings in Cloudflare Workers.Questions about documentation explaining memory management, lifetimes, and explicit resource disposal when using RPC via service bind...
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-java.textA JavaScript code example demonstrating the lifecycle of an RPC call within a Cloudflare Worker.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating the lifecycle of an RPC call within a Cloudflare Worker.
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-java-2.textA JavaScript code example demonstrating the implicit disposal of user symbols within a Cloudflare Workers RPC lifecycle scope.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating the implicit disposal of user symbols within a Cloudflare Workers RPC lifecyc...
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-java-3.textA JavaScript code example demonstrating the lifecycle of a Cloudflare Workers RPC service using a counter instance.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating the lifecycle of a Cloudflare Workers RPC service using a counter instance.
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-java-4.textA JavaScript code example demonstrating the lifecycle of a Cloudflare Workers RPC object using try-finally blocks and explicit disposal.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating the lifecycle of a Cloudflare Workers RPC object using try-finally blocks and...
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-java-5.textA JavaScript example demonstrating the Workers RPC lifecycle using an async fetch handler and service binding interaction.Exact payloads, commands, or snippets shown in A JavaScript example demonstrating the Workers RPC lifecycle using an async fetch handler and service binding interac...
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle.textA text-based demonstration of the Workers RPC lifecycle using a stub method call.Exact payloads, commands, or snippets shown in A text-based demonstration of the Workers RPC lifecycle using a stub method call.
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-disp.textA text example demonstrating the implementation of the Symbol.dispose method within a class extending RpcTarget to manage the Workers RPC lifecycle.Exact payloads, commands, or snippets shown in A text example demonstrating the implementation of the Symbol.dispose method within a class extending RpcTarget to ma...
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-stub.textA text example demonstrating how to duplicate and manage the lifecycle of RPC stubs within Cloudflare Workers.Exact payloads, commands, or snippets shown in A text example demonstrating how to duplicate and manage the lifecycle of RPC stubs within Cloudflare Workers.
examples/workers-runtime-apis-rpc-lifecycle-cloudflare-workers-rpc-lifecycle-java-6.textA JavaScript code example demonstrating the lifecycle of RpcTarget and RpcStub objects using the cloudflare:workers module.Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating the lifecycle of RpcTarget and RpcStub objects using the cloudflare:workers m...

What This Skill Covers

  • Lifetimes, Memory and Resource Management
  • Main sections: Lifetimes, Memory and Resource Management, Explicit Resource Management, How to use the using declaration in your Worker, Automatic disposal and execution contexts, End of event handler / execution context.

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/rpc/lifecycle