Remotion Vercel Sandbox Bugs Fixed

Build scripts promised speed. Delivered silence and slowness instead. Here's how two tiny bugs turned a slick Remotion Vercel Sandbox into a production nightmare.

Two Sneaky Bugs That Killed Our Remotion Vercel Sandbox — theAIcatchup

Key Takeaways

  • Anchor all paths to __dirname — relatives fail in Vercel envs.
  • Remotion bundles copy public/ folders; delete or disable before sandbox upload.
  • Remove error suppression in builds: fail fast over silent degradation.

Build scripts are liars.

They whisper promises of speed — pre-built snapshots for lightning-fast renders — then ghost you in production. Take Remotion on Vercel. We — or rather, some sharp devs — use it to churn out server-side video clips. The pitch? Bundle once at deploy, snapshot the sandbox, restore on demand. No cold-start hell. But last week, two bugs turned that dream toxic. Silent failures. Slow renders. OOM crashes lurking. And nobody noticed for days.

Why Did Relative Paths Betray Us?

Look. Node’s CWD isn’t your friend. It’s a fickle beast, shifting with the wind — especially in Vercel’s build sandbox. Picture this: your script calls addBundleToSandbox with bundleDir: '.remotion'. Cute. Relative. Works locally, where you’re king of the directory. CI? Usually fine. But Vercel? Sometimes it drifts. Wrong folder. Empty upload. Snapshot? A barren void.

The bug: we were passing a relative path: const BUNDLE_DIR = “.remotion”; // … await addBundleToSandbox({ sandbox, bundleDir: BUNDLE_DIR });

That’s the smoking gun. Straight from the post-mortem. It “succeeds” — no errors thrown — but uploads zilch. Workers restore nothing. Back to square one: full re-bundle every render. Sloooow.

Fix? One line of sanity. Anchor to __dirname. ESM style:

const __dirname = path.dirname(fileURLToPath(import.meta.url)); const bundleDir = path.resolve(__dirname, ../${BUNDLE_DIR});

Boom. Absolute path. Unbreakable. Lesson hammered home since Node’s early days — remember the 2012 npm path wars? Shrinkwrap.json eating relative dirs alive? History repeats if you let it. Devs today still trip here. Vercel’s opaque CWD? Asking for it.

But wait. Fix that, and bam — second bug.

Can Remotion Handle a Simple Public Folder?

No. Not really.

Remotion’s bundler — helpful guy — copies your public/ folder into the output. Fonts. Images. Assets for compositions. Logical, right? Except Vercel’s sandbox API? Flat-earth fanatic. addBundleToSandbox chokes on nested paths. public/fonts/Inter.woff2? Error. No recursive mkdir. Expects baby-steps: create public/, then public/fonts/, then file. Bundler doesn’t play nice.

Two fixes floated. Option A: publicDir: null in bundle(). Skip the copy. Fine if your videos don’t crave statics. Option B: Bundle, then rm -rf public/. Pre-upload purge.

They picked both. Belt, suspenders, paranoia.

We went with both: publicDir: null in bundle() plus the defensive rm as a belt-and-suspenders guard.

Smart. Future-proof. Because Remotion might flip defaults tomorrow. Who knows? Tooling evolves weird.

Here’s my hot take — Remotion’s docs gloss this. “Flat bundle expected.” Buried? Nonexistent? Feels like it. Echoes Webpack’s early publicPath gotchas. Devs waste hours reverse-engineering. Prediction: If Remotion doesn’t patch recursive uploads or warn boldly, every Vercel video shop hits this wall. Your Netflix clone? Doomed to debug purgatory.

Error Suppression: The Silent Killer

Worst part? Bugs screamed — quietly.

Package.json had this gem:

“vercel-build”: “next build && node scripts/create-snapshot.mjs || echo ‘[create-snapshot] Skipped (non-fatal)’”

Handy for staging. Token missing? No sweat. But prod? Degraded mode forever. Builds green. Workers limp. Renders crawl. Days pass. Nobody blinks.

Fix: Rip it out.

“vercel-build”: “next build && node scripts/create-snapshot.mjs”

Fail loud. Deploy dies. Problem surfaces. Obvious now, but — duh — hindsight’s 20/20.

This? Pure hubris. “Non-fatal” my foot. Reminds me of AWS Lambda’s early error-eating. Teams ran “successful” functions timing out forever. Cost them fortunes. Vercel era, same trap. Staging hacks bleed to prod. Stop it.

Why This Hits Server-Side Video Hard

Remotion’s magic: React to video. Server-side. Vercel scales it. Sandboxes snapshot for sub-second starts. Break that? You’re bundling per-request. 10s+ cold starts. OOM if bundle’s fat. Users bounce. Your viral clip generator? Snail-paced.

Devs chasing this stack — think AI video tools, dynamic thumbnails — you’re vulnerable. Vercel’s CWD whims? Undocumented. Remotion’s flat fetish? Unspoken. Stack ‘em, and poof: prod fire.

But skepticism time. Is this Remotion’s fault? Vercel’s? Yours? All three. Tooling assumes perfect envs. Reality laughs. Build scripts demand paranoia: absolutes, error-loud, defensive cleans.

One commit shipped all. Snapshot’s reliable now. Fast. But the scars? Teach volumes.

Is Your Vercel Build Hiding Nightmares?

Check it.

Relative paths anywhere? Nuke ‘em. || true fallbacks? Audit. Prod perf hinges on snapshots? Test CWD shifts. Mock Vercel’s env locally — process.chdir('/tmp') before scripts. Watch it burn.

Remotion users: publicDir: null yesterday. Rm guardrail forever. Vercel? Docs on CWD please. It’s 2024.

This saga? Microcosm of serverless pain. Promises collide with platforms. Winners paranoia-code. Losers? Green builds, red metrics.

Why Does This Matter for DevOps Teams?

Scale video rendering? Must-read.

But broader: Every edge-deploy tool — Next.js, Remix, whatever — flirts these bugs. CWD drift. Flat uploads. Muted fails. Your perf win? One bad assumption away.

My verdict: Solid fixes. But tooling lags. Remotion, Vercel — level up docs. Devs: Assume betrayal. Code accordingly.


🧬 Related Insights

Frequently Asked Questions

What caused the Remotion Vercel Sandbox bugs?

Two issues: relative paths resolving wrong due to CWD shifts, and public/ subdir breaking flat sandbox uploads. Both silent until prod meltdown.

How do you fix relative paths in Node build scripts?

Use path.resolve(__dirname, '../your-dir') or ESM’s import.meta.url. Ditch relatives — CWD lies.

Should you suppress errors in Vercel builds?

Never for prod-critical steps. Let deploys fail loud. Green builds hiding slowness? Worse than red.

Priya Sundaram
Written by

Hardware and infrastructure reporter. Tracks GPU wars, chip design, and the compute economy.

Frequently asked questions

What caused the Remotion Vercel Sandbox bugs?
Two issues: relative paths resolving wrong due to CWD shifts, and public/ subdir breaking flat sandbox uploads. Both silent until prod meltdown.
How do you fix relative paths in Node build scripts?
Use `path.resolve(__dirname, '../your-dir')` or ESM's `import.meta.url`. Ditch relatives — CWD lies.
Should you suppress errors in Vercel builds?
Never for prod-critical steps. Let deploys fail loud. Green builds hiding slowness

Worth sharing?

Get the best AI stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from theAIcatchup, delivered once a week.