export const runtime = 'edge' in app/opengraph-image.tsx blocked the entire Vercel deployment. Took 23 minutes to identify and revert.
Impact
Full deployment blocked. Every push to main failed during Vercel build. Site was not updated for 23 minutes while root cause was identified.
Root Cause
app/opengraph-image.tsx had export const runtime = 'edge' added during a refactor. The Edge Runtime does not support the Node.js crypto module, which next/og uses internally for image generation. Vercel's build succeeded locally (Node.js runtime) but failed on the edge worker.
Resolution
Removed the runtime export from opengraph-image.tsx. Next.js defaults OG image routes to the Node.js runtime, which is correct for next/og. The edge export was unnecessary and incorrect.
Prevention Pattern
Never add export const runtime = 'edge' to opengraph-image.tsx or route.ts files that use next/og or any Node.js built-ins. The edge runtime supports a restricted API surface — check the Vercel edge compatibility table before adding this export to any file.
Built from real execution
During a refactor pass on the app directory, I added export const runtime = 'edge' to app/opengraph-image.tsx to match the runtime declaration style I was using in some API route handlers.
The next push to main triggered a Vercel deployment that failed with:
Error: The Edge Runtime does not support Node.js 'crypto' module.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
The build had passed locally because next dev and next build both run in the Node.js runtime by default. The edge runtime restriction only fires on Vercel's actual edge workers.
| Time | Event |
|---|---|
| T+0 | Push to main, Vercel deployment triggered |
| T+2 | Build fails with Edge Runtime crypto error |
| T+5 | First look at build logs — error points to opengraph-image.tsx |
| T+12 | Confirmed root cause: runtime export added in recent refactor |
| T+18 | Reverted the runtime export, pushed fix |
| T+23 | Deployment succeeded |
The export const runtime = 'edge' pattern is valid and useful in API route handlers and middleware where you want the performance benefits of edge execution. Copying it into an OG image handler looks superficially correct.
The deceptive part: next build passes locally. The incompatibility only surfaces when Vercel actually runs the edge worker, which doesn't happen in local builds.
⚠Edge runtime compatibility surface
The Edge Runtime does NOT support: fs, path, crypto, buffer, stream, or most Node.js built-ins. It supports Web APIs only. Check the Next.js edge runtime docs before adding this export to any file.
Before adding export const runtime = 'edge' to any file:
next/og, sharp, or any image processingnext build with NODE_OPTIONS=--experimental-vm-modules to surface edge errors locallyFor OG image routes specifically: never add the edge runtime export. The Node.js runtime is correct and required.