🎥 Make videos programmatically with React
push
Jonny Burger0cac2f819f79
diff --git a/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.ts b/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.tsindex 971ef99dee..017eb6b998 100644--- a/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.ts+++ b/packages/template-vercel/src/app/api/render/sandbox/create-sandbox.ts@@ -10,6 +10,8 @@ import { installJsDependencies } from "./install-js-dependencies";import { installSystemDependencies } from "./install-system-dependencies";import { patchCompositor } from "./patch-compositor";+export const SANDBOX_CREATING_TIMEOUT = 5 * 60 * 1000;+export async function createSandbox({onProgress,}: {@@ -18,13 +20,11 @@ export async function createSandbox({const sandbox = await createDisposableSandbox({runtime: "node24",resources: { vcpus: 4 },- timeout: 5 * 60 * 1000,+ timeout: SANDBOX_CREATING_TIMEOUT,});const preparingPhase = "Preparing...";- const preparingSubtitle = process.env.VERCEL- ? "This only needs to be done once."- : "This is only needed during development.";+ const preparingSubtitle = "This is only needed during development.";// Preparation has 3 stages with weights:// - System dependencies: 60%diff --git a/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.ts b/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.tsindex b1f0e7258b..adc5a766fc 100644--- a/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.ts+++ b/packages/template-vercel/src/app/api/render/sandbox/reuse-or-create-sandbox.ts@@ -1,41 +1,32 @@import { Sandbox } from "@vercel/sandbox";import { createDisposableSandbox, OnProgressFn } from "../helpers";-import { createSandbox } from "./create-sandbox";+import { createSandbox, SANDBOX_CREATING_TIMEOUT } from "./create-sandbox";import { getCachedSnapshot } from "./snapshots";-const TIMEOUT = 5 * 60 * 1000;-export async function reuseOrCreateSandbox(onProgress: OnProgressFn,): Promise<Sandbox & AsyncDisposable> {- await onProgress({- type: "phase",- phase: "Creating sandbox...",- progress: 0,- });+ // During local development, a new sandbox is created from scratch always (no snapshotting)+ if (!process.env.VERCEL) {+ await onProgress({+ type: "phase",+ phase: "Creating sandbox...",+ progress: 0,+ });+ return await createSandbox({ onProgress });+ }// In production, the snapshot is created at build time via `create-snapshot`const cachedSnapshotId = await getCachedSnapshot();- if (cachedSnapshotId) {- try {- return await createDisposableSandbox({- source: { type: "snapshot", snapshotId: cachedSnapshotId },- timeout: TIMEOUT,- });- } catch {- if (process.env.VERCEL) {- throw new Error("Failed to create sandbox from snapshot");- }-- // In development, fall through to full setup- }- } else if (process.env.VERCEL) {+ if (!cachedSnapshotId) {throw new Error(- "No sandbox snapshot found. Run `bun run create-snapshot` first.",+ "No sandbox snapshot found. Run `bun run create-snapshot` as part of the build process.",);}- // Local development: create sandbox from scratch (no snapshotting)- return await createSandbox({ onProgress });+ return await createDisposableSandbox({+ source: { type: "snapshot", snapshotId: cachedSnapshotId },+ timeout: SANDBOX_CREATING_TIMEOUT,+ });}