Skip to content

Remove container-local preview port registry#710

Draft
ghostwriternr wants to merge 1 commit into
preview-stack-v2/02-preview-port-statefrom
preview-stack-v2/03-port-registry-decommission
Draft

Remove container-local preview port registry#710
ghostwriternr wants to merge 1 commit into
preview-stack-v2/02-preview-port-statefrom
preview-stack-v2/03-port-registry-decommission

Conversation

@ghostwriternr
Copy link
Copy Markdown
Member

@ghostwriternr ghostwriternr commented May 19, 2026

The container-local exposed-port registry was the container-side RPC/list used to remember which ports had been exposed for preview forwarding. After the earlier PRs in this stack, forwarding decisions use Sandbox Durable Object state instead, so this registry is duplicate state.

Keeping it around makes the lifecycle model harder to reason about and creates another place where preview URL state can drift from the Durable Object-owned forwarding decision.

This change removes the obsolete container-local exposed-port registry and leaves the container side responsible for port readiness/watch behaviour.

Removed registry surface includes the old expose/list/unexpose/proxy container APIs and their shared RPC/request types. The Sandbox SDK no longer exports the internal registry client used by those old container-local registry paths.

Removed registry-only exported/request types include ExposePortRequest, UnexposePortRequest, PortCloseResult, PortListResult, and PortStatusResult. PortExposeResult now reflects the Sandbox-level preview URL result shape.

Port readiness remains supported through the readiness/watch APIs, which check or wait for a process to listen on a port. The container PortService is now readiness-only, and the related tests focus on readiness behaviour instead of exposed-port registry state.

Docs and error suggestions are updated so they no longer describe the old container-local registry as the source of truth for preview URLs.

This does not remove the Sandbox Durable Object /proxy/:port compatibility path used by direct DO fetch flows such as switchPort() and wsConnect(). That path is separate from public preview URL traffic, which enters through the preview-hostname validation and forwarding path added earlier in the stack.

Preview URL authorization and activation now live in Sandbox Durable Object state:

  • portTokens records persistent token authorization;
  • activePreviewPorts records current-runtime activation;
  • currentRuntimeIdentity ties activation to the current container runtime, so activation from a previous restart is ignored.

The container-local registry no longer contributes to forwarding correctness. Removing it makes the ownership boundary explicit and reduces duplicate lifecycle state.

This PR completes the preview URL lifecycle stack. The stack should be released as one unit after the upstream @cloudflare/containers dependency is replaced with a published version containing Container.fetchIfRunning().


This is part 3 of 3 in the preview URL lifecycle stack:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

⚠️ No Changeset found

Latest commit: 00f819b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 1 package
Name Type
@cloudflare/sandbox Minor

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/sandbox-sdk/@cloudflare/sandbox@710

commit: 00f819b

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

🐳 Docker Images Published

Variant Image
Default cloudflare/sandbox:0.0.0-pr-710-00f819b
Python cloudflare/sandbox:0.0.0-pr-710-00f819b-python
OpenCode cloudflare/sandbox:0.0.0-pr-710-00f819b-opencode
Musl cloudflare/sandbox:0.0.0-pr-710-00f819b-musl
Desktop cloudflare/sandbox:0.0.0-pr-710-00f819b-desktop

Usage:

FROM cloudflare/sandbox:0.0.0-pr-710-00f819b

Version: 0.0.0-pr-710-00f819b


📦 Standalone Binary

For arbitrary Dockerfiles:

COPY --from=cloudflare/sandbox:0.0.0-pr-710-00f819b /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]

Download via GitHub CLI:

gh run download 26225403611 -n sandbox-binary

Extract from Docker:

docker run --rm cloudflare/sandbox:0.0.0-pr-710-00f819b cat /container-server/sandbox > sandbox && chmod +x sandbox

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 6 additional findings.

Open in Devin Review

@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/02-preview-port-state branch from 2c086b2 to 5497d28 Compare May 20, 2026 10:36
@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/03-port-registry-decommission branch from 73f0f73 to 38d505e Compare May 20, 2026 10:36
@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/02-preview-port-state branch from 5497d28 to 4de3df0 Compare May 20, 2026 13:56
@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/03-port-registry-decommission branch from 38d505e to 0bcb70d Compare May 20, 2026 13:56
@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/02-preview-port-state branch from 4de3df0 to 41402d2 Compare May 20, 2026 15:24
@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/03-port-registry-decommission branch from 0bcb70d to 45429b7 Compare May 20, 2026 15:24
@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/02-preview-port-state branch from 41402d2 to 651f1ad Compare May 21, 2026 12:17
@ghostwriternr ghostwriternr force-pushed the preview-stack-v2/03-port-registry-decommission branch from 45429b7 to 00f819b Compare May 21, 2026 12:17
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