Simplify Cloudflare Durable Object framework integration - #7385
Open
IMax153 wants to merge 3 commits into
Open
Conversation
|
| Name | Type |
|---|---|
| effect | Patch |
| @effect/ai-anthropic | Patch |
| @effect/ai-openai | Patch |
| @effect/ai-openai-compat | Patch |
| @effect/ai-openrouter | Patch |
| @effect/atom-react | Patch |
| @effect/atom-solid | Patch |
| @effect/atom-vue | Patch |
| @effect/docgen | Patch |
| @effect/doctest | Patch |
| @effect/openapi-generator | Patch |
| @effect/opentelemetry | Patch |
| @effect/platform-browser | Patch |
| @effect/platform-bun | Patch |
| @effect/platform-cloudflare | Patch |
| @effect/platform-deno | Patch |
| @effect/platform-node | Patch |
| @effect/platform-node-shared | Patch |
| @effect/sql-clickhouse | Patch |
| @effect/sql-d1 | Patch |
| @effect/sql-libsql | Patch |
| @effect/sql-mssql | Patch |
| @effect/sql-mysql2 | Patch |
| @effect/sql-pg | Patch |
| @effect/sql-pglite | Patch |
| @effect/sql-sqlite-bun | Patch |
| @effect/sql-sqlite-do | Patch |
| @effect/sql-sqlite-node | Patch |
| @effect/sql-sqlite-react-native | Patch |
| @effect/sql-sqlite-wasm | Patch |
| @effect/vitest | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Frameworks such as Alchemy can generate the native Durable Object class, but the existing integration requires consumers to reconstruct internal lifecycle details: manually retain an unsafe scope, register workflows inside the object isolate, branch on optional program readiness, forward every RPC method, and read the workflow namespace from an untyped Worker environment. Those steps are easy to attach to the wrong lifetime and make the class-independent API harder to use safely.
This change makes the Durable Object lifecycle explicit while keeping Effect Workflow, Cluster, and the Cloudflare runtime independent of any deployment framework.
Changes
program.readyhandling.blockConcurrencyWhile.getByNamecapability and both Promise- and Effect-valued workflow RPC methods.Alchemy integration
Alchemy can yield its generated Durable Object namespace directly and construct ordinary Layers during Worker initialization:
The generated Durable Object definition only obtains its platform state and returns
makeClusterWorkflowProgram(state.raw). It does not needWorkerEnvironment,Scope.makeUnsafe(), a readiness branch, registry knowledge, or method-by-method forwarding. Alchemy remains responsible only for deployment and native class generation.Lifecycle
Workflow registration is built in the Worker initialization scope, which Alchemy retains for the isolate lifetime. Durable Object reconstruction remains storage-driven, alarms recover execution identity from SQLite, and detached work continues through native
waitUntil. Native classes preserve their existing behavior while sharing the framework-neutral implementation.Validation
nix develop --command pnpm lint-fixnix develop --command pnpm --filter @effect/platform-cloudflare checkCloudflareWorkflowEngine.test.tsCloudflareDurableObjects.test.ts