Make sandbox work stick to one container - #833
Merged
ghostwriternr merged 29 commits intoJul 22, 2026
Merged
Conversation
Bind SDK operations to activated runtime incarnations so starts, streams, handles, forwarding, and teardown cannot cross runtime replacement.
Preview and tunnel workflows need one exact runtime authority across admission, side effects, transport lifetime, and durable publication. Keep discovery and stale-owner cleanup non-waking while preventing old sessions and interrupted callbacks from publishing runtime-owned state.
Keep archive transfer and cleanup under the same admitted runtime so a replacement cannot replay side effects or switch controls mid-attempt. Preserve independent sandbox-lifetime interruptions and durable restore ownership for explicit caller reconciliation.
Keep mount setup and long-lived local sync pinned to one runtime while making unmount and teardown cleanup non-waking. Exact incarnation and sandbox-lifetime fences prevent stale registry publication.
Keep extension control, sidecar connection, and callback streaming inside one admitted runtime so stale remotes cannot reconnect after replacement.
Delete transitional identity and transport retry paths so runtime work is admitted once, scoped to an exact incarnation, and never replayed.
Exercise deterministic real-container replacement and non-waking lookup paths while ensuring failed WebSocket closure cannot retain runtime authority.
Exercise real control-process replacement without assuming the container entrypoint is namespace PID 1.
🦋 Changeset detectedLatest commit: 3e1fbef 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-833-3e1fbef9Version: 📦 Standalone BinaryFor arbitrary Dockerfiles: COPY --from=cloudflare/sandbox:0.0.0-pr-833-3e1fbef9 /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]Download via GitHub CLI: gh run download 29941971984 -n sandbox-binaryExtract from Docker: docker run --rm cloudflare/sandbox:0.0.0-pr-833-3e1fbef9 cat /container-server/sandbox > sandbox && chmod +x sandbox |
ghostwriternr
force-pushed
the
naresh/stabilize-next-release
branch
from
July 21, 2026 15:08
4ea6fba to
6da925d
Compare
ghostwriternr
force-pushed
the
naresh/runtime-incarnation-admission
branch
from
July 21, 2026 15:08
f567cce to
aca7f4c
Compare
ghostwriternr
force-pushed
the
naresh/stabilize-next-release
branch
from
July 21, 2026 15:14
6da925d to
047dc46
Compare
ghostwriternr
force-pushed
the
naresh/runtime-incarnation-admission
branch
from
July 21, 2026 15:14
aca7f4c to
36c95b2
Compare
Restore sandbox environment and workspace defaults that were masked by cold-start admission failures. Observe completed stop boundaries in incarnation tests and fully destroy discarded warm containers before releasing capacity.
Use the upstream fix for stop events racing replacement startup instead of maintaining SDK-specific lifecycle fencing. Preserve JSON null environment values as explicit unsets.
Preserve watches, process logs, and terminal output across Workers RPC boundaries while retaining the inherited Container request APIs. Keep runtime replacement and control-plane routing explicit so callers do not attach resources to stale container incarnations.
Explicit restores must reapply committed backups when their destination has changed. Inactivity expiry must also complete without re-entering the sandbox stop gate, while E2E workflows synchronize on observable process and terminal behavior.
Characterize Durable Object memory loss separately from persisted Sandbox configuration across eviction and local Worker reloads. Align the local Cloudflare test toolchain so the real container-backed harness remains reproducible.
Allow the first waking establishment after a physical stop to clean up the previous runtime without treating its delayed onStop bookkeeping as invalidation of the sequential replacement.
Route container start and stop hooks through replacement-start marking and observed-stop reconciliation while keeping explicit stop and destroy as hard invalidations.
Control-server exit can surface stopped_with_code when the monitor reports a numeric exit code. Match the wait helper.
Rewrite the PR #833 changesets in plain language so release notes describe user-visible behavior instead of internal runtime jargon.
ghostwriternr
marked this pull request as ready for review
July 22, 2026 17:23
ghostwriternr
merged commit Jul 22, 2026
e5c529b
into
naresh/stabilize-next-release
14 of 15 checks passed
ghostwriternr
added a commit
that referenced
this pull request
Jul 22, 2026
* Serialize branch release workflows Prevent an older build from replacing a newer Worker and container release when several commits reach a release branch close together. * Make terminal output assertion deterministic Shell prompts can arrive before command output, so collect terminal data until the expected command result is observed. * Declare sandbox execution workspace version Preview publishing resolves workspace dependency versions and requires every internal package to declare one. * Clean up failed E2E sandboxes Destroy partially initialized sandboxes so failed environment setup does not leak resources into disposable pull request deployments. * Pull process events across RPC Worker RPC stream capabilities can close without delivering retained process events. Pull each event explicitly and keep runtime control alive until the local subscription settles. * Make sandbox work stick to one container (#833) * Establish runtime operation admission Bind SDK operations to activated runtime incarnations so starts, streams, handles, forwarding, and teardown cannot cross runtime replacement. * Fence preview and tunnel operations Preview and tunnel workflows need one exact runtime authority across admission, side effects, transport lifetime, and durable publication. Keep discovery and stale-owner cleanup non-waking while preventing old sessions and interrupted callbacks from publishing runtime-owned state. * Fence backup operations to one runtime Keep archive transfer and cleanup under the same admitted runtime so a replacement cannot replay side effects or switch controls mid-attempt. Preserve independent sandbox-lifetime interruptions and durable restore ownership for explicit caller reconciliation. * Thread runtime leases through mounts Keep mount setup and long-lived local sync pinned to one runtime while making unmount and teardown cleanup non-waking. Exact incarnation and sandbox-lifetime fences prevent stale registry publication. * Scope extension workflows to runtimes Keep extension control, sidecar connection, and callback streaming inside one admitted runtime so stale remotes cannot reconnect after replacement. * Remove implicit runtime ownership Delete transitional identity and transport retry paths so runtime work is admitted once, scoped to an exact incarnation, and never replayed. * Add runtime lifecycle regressions Exercise deterministic real-container replacement and non-waking lookup paths while ensuring failed WebSocket closure cannot retain runtime authority. * Test control server exit recovery Exercise real control-process replacement without assuming the container entrypoint is namespace PID 1. * Fix runtime execution regressions Restore sandbox environment and workspace defaults that were masked by cold-start admission failures. Observe completed stop boundaries in incarnation tests and fully destroy discarded warm containers before releasing capacity. * Upgrade container lifecycle handling Use the upstream fix for stop events racing replacement startup instead of maintaining SDK-specific lifecycle fencing. Preserve JSON null environment values as explicit unsets. * Stabilize sandbox proxy transports Preserve watches, process logs, and terminal output across Workers RPC boundaries while retaining the inherited Container request APIs. Keep runtime replacement and control-plane routing explicit so callers do not attach resources to stale container incarnations. * Stabilize lifecycle regression workflows Explicit restores must reapply committed backups when their destination has changed. Inactivity expiry must also complete without re-entering the sandbox stop gate, while E2E workflows synchronize on observable process and terminal behavior. * Add Sandbox reconstruction harness Characterize Durable Object memory loss separately from persisted Sandbox configuration across eviction and local Worker reloads. Align the local Cloudflare test toolchain so the real container-backed harness remains reproducible. * Reconcile delayed runtime stops Allow the first waking establishment after a physical stop to clean up the previous runtime without treating its delayed onStop bookkeeping as invalidation of the sequential replacement. * Wire pending stop reconciliation Route container start and stop hooks through replacement-start marking and observed-stop reconciliation while keeping explicit stop and destroy as hard invalidations. * Accept both terminal container stop statuses Control-server exit can surface stopped_with_code when the monitor reports a numeric exit code. Match the wait helper. * Bump E2E deploy hash for CI rerun * Bump E2E deploy hash again * Add isolated browser test containers * Parallelize isolated browser tests * Integrate browser container readiness * Fix browser test import order * Bound browser test concurrency * Bootstrap Wrangler in rollout checks * Reduce browser cold-start pressure * Limit browser cold starts to one * Avoid orphaned browser configuration * Restore parallel browser coverage * Clarify release notes for callers Rewrite the PR #833 changesets in plain language so release notes describe user-visible behavior instead of internal runtime jargon.
14 tasks
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.
Make sandbox work stick to one container at a time
A Sandbox Durable Object can outlive the container it is talking to. After sleep, eviction, or a crash, Cloudflare may start a replacement container under the same Durable Object.
Without this change, an old process handle, stream, WebSocket, backup, mount, tunnel, or extension sidecar could keep talking to the new container as if nothing happened. That can drop output, attach to the wrong process, or run the same side effect twice.
This PR ties each piece of work to the exact container that started it.
What callers should expect
Also included
/workspacedefault working directory are applied on process launch again.@cloudflare/containersis upgraded so stop and replacement startup no longer race each other.withRuntime()andwithSidecar()instead of keeping long-lived runtime clients.This PR is stacked on #827. Retarget it to
nextafter #827 merges.Out of scope
Typed error details for some Worker RPC process-stream failures are deferred to a follow-up. The no-retry and container-binding behavior already land here.