Restore port config changes (#490, #535)#540
Draft
ghostwriternr wants to merge 3 commits intomainfrom
Draft
Conversation
* Make container control plane port configurable via SANDBOX_CONTROL_PORT env var * Propagate configurable control port through SDK and shared types * Update Dockerfiles * Add tests * Update existing tests * Add e2e tests * Add changeset * Fix e2e tests * Bonk changes * Remove unneeded test + provide templating for control port in docker files * Update markdown files * Make port configurable * Address bonk's comments * Address Devin comments * Address Devin * Change changeset to patch * Fix missing import * Move control port validation into the Durable Object (#528) The configurable control port feature threaded getControlPort through proxy-side functions (connect, enhanceSession, proxyTerminal, terminal). This is unnecessary because the DO already owns defaultPort and handles routing via Container.fetch. Port validation now uses the cf-container-target-port header in Sandbox.fetch(), which correctly distinguishes user WebSocket connections from control-plane WebSockets without fragile path exemptions. The legacy fallback remap is fixed to work with custom SANDBOX_CONTROL_PORT values, not just the default. --------- Co-authored-by: Muhammad Ali <muhammadali@cloudflare.com> Co-authored-by: Naresh <ghostwriternr@gmail.com>
…holders (#535) * Resolve CodeInterpreter client lazily via getter The constructor captured sandbox.client.interpreter once. After the legacy port fallback recreated this.client, the interpreter kept using the stale reference, causing instant 500s for all interpreter calls while exec() worked fine on the new client. * Add container startup to WebSocket upgrade path The WebSocket branch of Sandbox.fetch() called super.fetch() without ensuring the container was started, bypassing the legacy port fallback entirely. Extract checkContainerState(), startContainer(), and handleStartupError() from containerFetch() and reuse them in the WebSocket branch so both transports get identical startup, fallback, and error classification behavior. * Accept client-getter in LocalMountSyncManager Same stale-client pattern as CodeInterpreter: the constructor stored a direct reference to this.client which went stale after fallback. Accept a getClient closure instead so active mounts always resolve the current client. * Add inline comments at client resolution sites * Add changeset * Use canonical logging and stop leaking error messages in responses Startup error classification now uses logCanonicalEvent() with credential redaction instead of raw logger calls. Error details are logged server-side only — response bodies no longer include e.message in the context field.
🦋 Changeset detectedLatest commit: 58b2874 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
Contributor
🐳 Docker Images Published
Usage: FROM cloudflare/sandbox:0.0.0-pr-540-58b2874Version: 📦 Standalone BinaryFor arbitrary Dockerfiles: COPY --from=cloudflare/sandbox:0.0.0-pr-540-58b2874 /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]Download via GitHub CLI: gh run download 23745698168 -n sandbox-binaryExtract from Docker: docker run --rm cloudflare/sandbox:0.0.0-pr-540-58b2874 cat /container-server/sandbox > sandbox && chmod +x sandbox |
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.
Summary
Restores the port config changes that were reverted in #536:
Context
#490 changed the container control port from 3000 to 8671, with a legacy fallback for containers still running on 3000. The fallback had gaps that caused failures when rolling out the new SDK version to workers with already-running containers — the same upgrade path production users would hit. #535 attempted to address those gaps.
After reverting and re-investigating, we also discovered a separate platform-level container scheduling issue that compounded the failures. That is being reported to the Containers team separately.