Skip to content

No way to attach a container to a Durable Object declared on an async (non-Effect) Worker #953

Closed

Description

@nkochly

What we're trying to do

Our Worker is a plain async module. It hosts a container-backed Durable Object whose class comes from an npm package (@cloudflare/sandbox's Sandbox), re-exported from the Worker entrypoint. We declare it the async way:

const app = Cloudflare.Worker("App", {
  main: "./src/worker.ts",
  env: {
    Sandbox: Cloudflare.DurableObject<Sandbox>("Sandbox"),
  },
});

This uploads the DO namespace binding and the new_sqlite_classes migration, but the script metadata never gets a containers: [{ className: "Sandbox" }] entry, so Cloudflare does not treat the class as container-backed.

Why it appears unsupported (2.0.0-beta.64 source)

  • WorkerAsyncBindings.ts has no container branch — nothing in the async env path can contribute containers binding data.
  • The only producer of that data is ContainerPlatform.bind (ContainerPlatform.ts:137-139), which requires the Effect-native DurableObjectScope — unreachable for a plain async DO class from an npm package.
  • WorkerProvider derives metadata.containers exclusively from bindings data (WorkerProvider.ts:1717-1722, :1851-1855), so there is no prop-level escape.
  • Separately, ContainerProvider always docker pulls and re-pushes (ContainerProvider.ts:314-324; the create path is unguarded at :936) even when image is a digest reference already in the account's registry.cloudflare.com — no skip path for pre-pushed images.

Feature request

  1. Let async Workers declare a container-backed DO, e.g. Cloudflare.DurableObject<Sandbox>("Sandbox", { container: SandboxContainer }) or container handling in the async env binding path.
  2. Skip the Docker round-trip when image is a digest reference that already exists in the target registry (or offer push: false).

Workaround we found

worker.bind() with raw { containers: [{ className, dev: undefined }] } binding data, plus managing the ContainerApplication out-of-band. It works, but it leans on undocumented binding internals.

Context: this came up migrating a seven-Worker production app (Cloudflare-native, async Workers throughout) to Alchemy v2. Happy to test a fix or expand on any of the source references.

Activity

  1. added a commit that references this issue on Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions