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.
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
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/workers-runtime-apis-rpc-lifecycle-workflow-guide.md | Documentation 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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.text | A 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
- 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/rpc/lifecycle
