← 回總覽

Vercel Sandbox 现已支持自动持久化(Beta 版) - Vercel

📅 2026-03-27 06:32 Marc Codina Segura, Andy Waller, Tom Lienard, Luke Phillips-Sheard, Harpreet Arora 软件编程 4 分鐘 4078 字 評分: 85
Vercel Vercel Sandbox 云计算 DevOps 持久化
📌 一句话摘要 Vercel 为 Vercel Sandbox 推出了自动文件系统持久化功能(Beta 版),允许沙盒在停止时保存状态,并在恢复时自动还原,无需手动快照。 📝 详细摘要 Vercel 宣布 Vercel Sandbox 自动持久化功能进入 Beta 测试阶段。该功能实现了存储与计算的分离,使沙盒能够在会话结束时自动对文件系统状态进行快照,并在新会话开始时进行恢复。开发者现在可以使用更新后的 Beta 版 SDK 和 CLI 更轻松地管理长期运行的持久化沙盒。主要改进包括透明的会话管理(SDK 会自动重启已停止的沙盒)、动态扩展 vCPU 等资源的能力,以及用于列出、搜索和删

Title: Automatic persistence now in beta on Vercel Sandbox - Vercel | BestBlogs.dev

URL Source: https://www.bestblogs.dev/article/46e7d520

Published Time: 2026-03-26 22:32:02

Markdown Content: Sign in to use highlight and note-taking features for a better reading experience. Sign in now

2 min read

Mar 26, 2026 Vercel Sandboxes can now automatically save their filesystem state when stopped and restore it when resumed. This removes the need for manual snapshots, making it easier to run long-running, durable sandboxes that continue where you left off.

Link to headingHow it works

A sandbox is the durable identity, now identified by a name, its filesystem state, and configuration options. A session is the compute tied to that state, invoked as needed. Automatic persistence introduces orchestration that separates storage from compute, reducing the need for manual snapshotting, so:

* when you stop a sandbox, the session shuts down but the filesystem is automatically snapshotted.

* when you resume, a new session boots from that snapshot. This state storage is not charged, so you pay when your setting is active. import { Sandbox } from '@vercel/sandbox';// Create a named sandboxconst sandbox = await Sandbox.create({ name: 'user-a-workspace' });await sandbox.runCommand('npm', ['install']);await sandbox.stop();// Later, resume where you left offconst sandbox = await Sandbox.get({ name: 'user-a-workspace' });await sandbox.runCommand('npm', ['run', 'dev']);

Persistence is enabled by default in the beta SDK, can be disabled between sessions with persistent: false. When disabled, the sandbox still exists after being stopped and can be resumed by its name, but each session starts with a clean filesystem.

I f a sandbox is stopped and you run a command, the SDK will transparently create a new session, so you don't need to check state or manually restart const sandbox = await Sandbox.create({ name: "long-lived-sandbox" });await sandbox.writeFiles([{ path: "run.sh", content: Buffer.from('#!/bin/bash\necho "ready"'), mode: 0o755,}]);// Days laterconst resumedSandbox = await Sandbox.get({ name: "long-lived-sandbox" });console.log(resumedSandbox.status); // stopped automaticallyawait resumedSandbox.runCommand("./run.sh"); // "Hello!"console.log(resumedSandbox.status); // running

The beta SDK adds methods for managing sandboxes over their lifetime: const sandbox = await Sandbox.get({ name: 'user-alice' });// Scale up resources on a running sandboxawait sandbox.update({ resources: { vcpus: 4 } });// Inspect session history and snapshotsconst { sessions } = await sandbox.listSessions();const { snapshots } = await sandbox.listSnapshots();// Search across sandboxesconst { sandboxes } = await Sandbox.list({ namePrefix: 'user-', sortBy: 'name',});// Permanently remove a sandbox and all its dataawait sandbox.delete();

The beta CLI adds configuration management and session inspection: # Spin up a sandbox for a user sandbox create --name user-alice # User runs commands — if the sandbox timed out, it resumes automatically sandbox run --name user-alice -- npm test # Check what happened across sessions sandbox sessions list user-alice # Tune resources without recreating sandbox config vcpus user-alice 4 sandbox config timeout user-alice 5h

This feature is in beta and requires upgrading to the beta SDK and CLI packages.

Install the beta packages to try persistent sandboxes today: pnpm install @vercel/sandbox@beta for the SDK, andpnpm install -g sandbox@beta for the CLI.

Persistent sandboxes are available in beta on all plans.

Learn more in the documentation.

查看原文 → 發佈: 2026-03-27 06:32:02 收錄: 2026-03-27 08:00:41

🤖 問 AI

針對這篇文章提問,AI 會根據文章內容回答。按 Ctrl+Enter 送出。