Skip to content

[Sandbox, Containers] Fix examples and snapshot facts - #34571

Closed
ghostwriternr wants to merge 5 commits into
sandbox/audit-mechanicalfrom
sandbox/audit-code
Closed

ghostwriternr wants to merge 5 commits into
sandbox/audit-mechanicalfrom
sandbox/audit-code

Conversation

@ghostwriternr

Copy link
Copy Markdown
Member

Summary

Several Sandbox examples broke under overlapping requests or a Durable Object restart, and two pages described container behavior incorrectly.

  • Two requests that opened a tunnel for the same port at once each restarted cloudflared, so one tunnel could leak. Tunnels now share one start per port.
  • Clone a private repository set the inactivity timeout only after start(), so a restarted Durable Object dropped it, and a second request ran git clone into a full /workspace. The guide now restores the timeout in the constructor, skips the clone when /workspace/.git exists, and shares one clone between overlapping requests.
  • The DirectoryBackup reference told readers to call intercept() again after a Durable Object restart. The routes belong to the container and survive the restart, and their order is fixed until a new container starts. The reference now says so, and the setup moves to Back up a directory to R2, which registers the backup route before the catch-all on each new container.
  • The Containers snapshots guide said a snapshot captures the full container filesystem. It now names the writable root filesystem and what it leaves out.
  • Replacing a file in one step and listing a directory tree move from the Files reference to Manage files, as Durable Object methods that a Worker can call over RPC.

Documentation checklist

Two requests that opened a tunnel for the same port at once each
stopped and started cloudflared in the same directory, so one tunnel
could leak and the recorded process ID could belong to the process
that exited, the race the server page already guards against.

Keep one start promise per port, so overlapping requests wait for
the same start and get the same URL.
The Files reference held two procedures, replacing a file through a
temporary file and walking a directory tree, which belong in a how-to
and were written as fragments that a reader could not call over RPC.

Add Replace a file in one step and List a directory tree to the file
how-to as Durable Object methods, and link them from the reference.
The clone how-to set the inactivity timeout only after start(), so a
restarted Durable Object dropped it, and a second request ran git
clone into a full /workspace and failed. Two requests at once each
started a clone.

Restore the timeout in a constructor, skip the clone when the running
container already has /workspace/.git, and share one clone between
requests that overlap.
The DirectoryBackup reference told readers to call intercept() again
whenever a restarted Durable Object found the container running, and
held the setup code for that. A deploy probe showed that the routes
belong to the container and survive a restart, and that their order
is fixed until a new container starts.

State those facts in the reference, and move the setup into the
backup how-to as a shared setup that registers the backup route
before the catch-all on each new container.
The snapshots guide said a snapshot captures the full container
filesystem and its complete filesystem state. snapshotContainer()
saves only the writable root filesystem: separately mounted
filesystems and the tmpfs at /run start empty after a restore.

Name the writable root filesystem and list what it leaves out.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://sandbox-audit-code.previews.developers.cloudflare.com (commit c8deaf4)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://c577d371.previews.developers.cloudflare.com c8deaf4 2026-10-23T16:35:02.002Z Visit the dashboard ↗

@github-actions

Copy link
Copy Markdown
Contributor

@cloudflare-docs-bot

Copy link
Copy Markdown
Contributor

@ghostwriternr This draft pull request has had no activity for 3 days. It will close after 7 days of inactivity. Transition to ready for review if ready. A codeowner can comment /draft-never-stale to keep it open.

@cloudflare-docs-bot

Copy link
Copy Markdown
Contributor

@ghostwriternr Closing this draft pull request after 7 days of inactivity. Re-open at a later date and transition to ready for review when you are ready if you seek review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant