Loading...
Loading...
Use when porting a Cloudflare Sandbox app from stable @cloudflare/sandbox to @cloudflare/sandbox@next (Sandbox SDK 1.0 preview), or when the user asks to migrate or upgrade to Sandbox 1.0 / @next. Not for day-to-day stable work (sandbox-stable) or new @next apps (sandbox-next).
npx skill4agent add cloudflare/skills sandbox-migrate-to-next@next@nextsandbox-nextsandbox-stable@next@next@next@nextawait sandbox.exec(...)timeoutAbortSignalgitCheckout| Stable | |
|---|---|
| Remove — RPC only |
| |
| Same handle: |
| Default / named sessions | Gone — |
| |
xterm | |
Interpreter methods on | |
| argv |
| String kill signals | Numeric only |
Files, mounts, backups, ports, tunnels, | Mostly unchanged (ignore session/transport bits on stable pages) |
sandbox-nextrg 'SANDBOX_TRANSPORT|transport:|setTransport|enableDefaultSession|createSession|getSession|deleteSession|execStream\(|startProcess\(|killProcess\(|sandbox\.terminal\(|sessionId|gitCheckout\(|SandboxTransport|ExecutionSession'exec(cdexeccreateCodeContextrunCodeSandbox--containers-rollout=immediate-pythonnpm install @cloudflare/sandbox@nextFROM cloudflare/sandbox:next
# Python: cloudflare/sandbox:next-pythonnext| Area | Doc |
|---|---|
| Commands / handles / waits | Processes · Processes API |
| Environment · Outbound traffic |
| Drop sessions | Migrate · Lifecycle |
| Terminals | Terminals |
| Interpreter | Interpreter |
| Errors | Errors |
| Durable job across requests | Process execution — lifetime / durability |
// Before (stable)
const result = await sandbox.exec("npm test");
// After (@next)
const process = await sandbox.exec(["/bin/bash", "-lc", "npm test"]);
const result = await process.output({ encoding: "utf8" });const server = await sandbox.exec(["/bin/bash", "-lc", "npm run dev"], {
cwd: "/workspace/app",
});
await server.waitForPort(3000, { timeout: 60_000 });
await server.kill(); // numeric; default 15const terminal = await sandbox.createTerminal({ command: ["bash"], cwd: "/workspace" });
const t = await sandbox.getTerminal(terminal.id);
if (!t) return new Response("terminal gone", { status: 410 });
return t.connect(request, { cursor, cols, rows });import { Sandbox as BaseSandbox } from "@cloudflare/sandbox";
import { withInterpreter } from "@cloudflare/sandbox/interpreter";
export class Sandbox extends BaseSandbox<Env> {
interpreter = withInterpreter(this);
}const clone = await sandbox.exec(
["git", "clone", "--depth", "1", "--", repoUrl, "/workspace/repo"],
{ cwd: "/workspace" },
);
const result = await clone.output({ encoding: "utf8" });npx wrangler deploy --containers-rollout=immediaterollout_active_grace_period00@next@nextexecoutput({ encoding: "utf8" })--containers-rollout=immediatesandbox-next@nextawait execcdexecgitCheckoutsetEnvVarsenv