Align preview port APIs with forwarding#709
Draft
ghostwriternr wants to merge 1 commit into
Draft
Conversation
|
| 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
This was referenced May 19, 2026
commit: |
Contributor
📦 Preview BuildVersion: Install the SDK preview:
|
ccfb032 to
61c6d64
Compare
4de3df0 to
41402d2
Compare
41402d2 to
651f1ad
Compare
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.
After preview forwarding becomes current-runtime scoped, the public preview-port APIs need to report the same state that forwarding uses. Otherwise users can see a port reported as exposed even though its preview URL is stale and cannot forward without an explicit
exposePort()call in the current runtime.In this stack, persistent token authorization means the preview token is still valid, while current-runtime activation means
exposePort()has been called for that port in the currently running container runtime.This change aligns the public preview-port surface with that model.
getExposedPorts(hostname)now reports only ports whose preview URLs can be used without anotherexposePort()call: a valid token exists, the sandbox has a current runtime, and the port activation was created for that runtime.isPortExposed(port)now answers the same question for one port. It no longer treats persistent token authorization alone as proof that the preview URL can forward.unexposePort(port)is now idempotent Durable Object-owned revocation. It clears token authorization and runtime activation without waking or reaching the container.exposePort()andunexposePort()no longer depend on the old container-local exposed-port registry RPCs. The Sandbox Durable Object’s token and activation records are now the source of truth for deciding whether preview traffic may forward.The desktop preview integration now also obtains URLs through
exposePort(). It can no longer synthesize a URL from a persisted token whenexposePort()fails to create current-runtime activation.This PR intentionally does not delete the old container-local registry. It only stops the public Sandbox preview-port surface from relying on it. The registry deletion happens in the next PR once the new source of truth is in place.
This is part 2 of 3 in the preview URL lifecycle stack:
main