Two Subtle Bugs That Broke Our Remotion Vercel Sandbox (And How We Fixed Them)
We use Remotion to render video clips server-side, and we pre-build a Vercel Sandbox snapshot at deploy time so renders can restore it for fast cold starts instead of bundling from scratch on every...

Source: DEV Community
We use Remotion to render video clips server-side, and we pre-build a Vercel Sandbox snapshot at deploy time so renders can restore it for fast cold starts instead of bundling from scratch on every request. The flow looks like this: next build compiles the Next.js app node scripts/create-snapshot.mjs bundles the Remotion project, uploads it to a sandbox, takes a snapshot, and stores the snapshot ID in Vercel Blob Render workers restore the snapshot instead of re-bundling Last week, two separate bugs caused this to silently break in production. Here's what happened and what we changed. Bug 1: Relative path passed to addBundleToSandbox The @remotion/vercel package's addBundleToSandbox function uploads every file in the bundle directory to the sandbox. Under the hood it reads the directory, creates each file path in the sandbox, and streams the content. The bug: we were passing a relative path: const BUNDLE_DIR = ".remotion"; // ... await addBundleToSandbox({ sandbox, bundleDir: BUNDLE_DI