Skip to content

feat(containers): durable_object scheduling policy and ctx.container in local runs - #5

Merged
Refzlund merged 8 commits into
nextfrom
feat/container-durable-object-scheduling
Nov 30, 2026
Merged

Refzlund merged 8 commits into
nextfrom
feat/container-durable-object-scheduling

Conversation

@Refzlund

Copy link
Copy Markdown
Owner

Draft, to run Workspace CI. Do not merge: merging into next publishes the changeset to npm, and the release is the owner's call.

What

  • containers[] accepts schedulingPolicy: 'durable_object' with named images (Dockerfile or digest-pinned registry image). It compiles to Wrangler's class_name, scheduling_policy, name, images; the schema refuses image, instanceType, maxInstances and rollouts there, as Wrangler does.
  • devflare dev and createTestContext() build each named image with Docker/Podman (linux/amd64), pull Miniflare's egress interceptor, and attach the container to its Durable Object in Miniflare with SQLite storage — the same option shape wrangler dev produces (checked against unstable_getMiniflareWorkerOptions in a unit test).
  • The test gateway exports the WorkerEntrypoint classes of a container-backed DO module, so intercepts can target ctx.exports.<Name>.
  • Windows is refused (workerd cannot reach the Docker named pipe; measured), workspace dev refuses such an app, DEVFLARE_ENABLE_CONTAINERS=0 opts out.
  • New durable-object-containers job in Workspace CI runs the engine-backed integration test on the runner's Docker and fails if it would skip.

Changeset: minor.

🤖 Generated with Claude Code

…run locally through ctx.container

A container entry may set schedulingPolicy: 'durable_object' with named
images. It compiles to the fields Wrangler takes for that policy
(class_name, scheduling_policy, name, images), and the schema refuses the
application-wide fields Wrangler rejects there.

devflare dev and createTestContext() build each named image with Docker or
Podman, pull Miniflare's egress interceptor, and attach the container to its
Durable Object in Miniflare with SQLite storage, the shape wrangler dev uses.
The test gateway exports a container-backed module's WorkerEntrypoint
classes so outbound intercepts can target ctx.exports. Windows is refused
(workerd cannot reach a named pipe), workspace dev refuses such an app, and
DEVFLARE_ENABLE_CONTAINERS=0 turns local containers off.

A new workspace-ci job runs the engine-backed test on the runner's Docker
and fails if it would skip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1f352be

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
devflare Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…sertions, and the Wrangler parity test in a serial lane

Importing Wrangler in the unit lane left two other files holding a
method-less Miniflare on Linux CI, so the parity test moves to the serial
test-context lane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…side their own tests

mock.module is process-global and the unit lane runs every file in one
process in directory order. Adding test files on Linux put
simple-context-runtime.test.ts before simple-context-multi-worker and
local-secrets, which then built its FakeMiniflare (no dispose, fake
getBindings). The mocks now fake only while that file's tests run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-tested, builds load into the engine's store

- red: the devflare dev path had never run a real container and no test
  reached its wiring. A dev-server integration test now drives the same
  Durable Object through createDevServer, and the CI container job runs it.
- docker builds pass Wrangler's --load and --provenance=false, so a buildx
  docker-container builder cannot keep the image out of the store.
- Podman on macOS reads the machine's host-side socket.
- a container class that failed to bundle names the bundle error; the
  workspace refusal runs before anything starts; the refusal for an
  unserved class no longer sends readers to another worker, and the docs
  say referenced workers' containers do not run locally.
- the deprecation and 2026-12-31 claims name their sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… locally

A config that reaches a container only through a worker it references (a ref()
service binding, or a cross-worker Durable Object binding to its class) now gets
that worker's containers in createTestContext() and devflare dev: devflare builds
the images from the referenced config, attaches them where it hosts that worker's
Durable Objects, and exports the WorkerEntrypoint classes their modules declare so
an intercept can target ctx.exports. workspace dev refuses such an app, and the
Vite plugin leaves them out, as documented.

Graded end to end by three new container-lane integration tests (service binding,
cross-worker DO ref, devflare dev) and by unit tests of the refuse, ignore and
turned-off modes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- resolve-service-bindings.ts was 1,147 lines against the 1,000-line ceiling,
  which reddened validate. The referenced-container decision moves to
  referenced-containers.ts, and Bun detection, the bundle cache and the
  Durable Object host bundler to durable-object-bundle.ts (906 lines left;
  clearBundleCache and ReferencedContainerMode are still exported from it).
- A referenced worker's container engine reaching Miniflare was graded by
  nothing, because Miniflare's default socket hid a dropped option. The
  test-context merge moves into applyMultiWorkerConfig, and unit cases on a
  non-default socket grade it there and in buildMiniflareDevConfig.
- The workspace-dev refusal was graded only through the function it calls.
  A test now runs prepareWorkspaceApp against an app that references a
  container-backed builder.
- Docs no longer say a cross-worker Durable Object ref's containers run under
  devflare dev, which resolves no such refs. They say the devflare dev path
  is tested for a worker-only project.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p dirs

The Durable Object host bundler moved out of resolve-service-bindings.ts and
still writes its temporary entry beside the classes it bundles, so the census
of hardcoded .devflare paths names the new file with the same reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resolve-service-bindings now imports the container modules, which brings
src/test/containers.ts into apps/documentation's svelte-check. Under
@cloudflare/workers-types, Request.clone() is typed with the class's own
generic parameters, which fetch does not accept, so that check failed on
fetchWithStartupRetries. The clone is asserted back to Request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions
github-actions Bot had a problem deploying to testing branch preview / feat/container-durable-object-scheduling November 30, 2026 17:05 Failure
@Refzlund
Refzlund marked this pull request as ready for review November 30, 2026 18:08
@Refzlund
Refzlund merged commit 1f352be into next Nov 30, 2026
8 of 9 checks passed
@Refzlund
Refzlund deleted the feat/container-durable-object-scheduling branch November 30, 2026 18:43

This branch had an error being deployed

1 failed and 3 active deployments
testing branch preview / next — 1f352be8 Deployed Nov 30, 2026 by github-actions[bot]
documentation branch preview / next — 1f352be8 Deployed Nov 30, 2026 by github-actions[bot]
documentation branch preview / feat/container-durable-object-scheduling — 1f352be8 Deployed Nov 30, 2026 by github-actions[bot]
testing branch preview / feat/container-durable-object-scheduling — 1f352be8 Deployed Nov 30, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant