Vercel runtime errors
Status: đ© COMPLETE (đŠ LIVING â Vercel runtime evolves with platform updates) Last updated: 2026-06-21 Plain-English tagline: Errors that happen AFTER deploy succeeds â function timeouts, 500s, edge runtime quirks, the Vercel-specific runtime gotchas. For build-time failures, see Build errors.
What this is
A reference for errors that show up in Vercel Runtime Logs (the live log stream from your serverless and edge functions after a successful deploy). These are different from build errors â the deploy worked, but something fails when a real request hits your app.
For build-time problems (npm run build failing): see Build errors đ©.
Where to look
In the Vercel dashboard:
- Deployments tab â click a deployment â âRuntime Logsâ
- Filter by route, status code, deployment
- Logs stream in real time; recent ones are searchable
In CLI: vercel logs --follow tails recent logs.
âFunction execution timed outâ
What it means: Your serverless function ran past its time limit.
Limits by tier (as of 2026):
- Hobby: 10 seconds
- Pro: 60 seconds default, configurable up to 800 seconds via
vercel.json - Enterprise: longer
Common causes:
- Long-running LLM call. Anthropic / OpenAI calls can take 5â30 seconds for big outputs.
- Synchronous heavy computation. Image processing, large CSV generation.
- Database query that scans a large table. Missing indexes.
- External API thatâs slow or hanging.
Fix paths:
- Increase the limit (Pro tier only). In
vercel.json:{ "functions": { "app/api/heavy/route.ts": { "maxDuration": 60 } } } - Stream the response. For LLM calls, use Server-Sent Events so the user sees output as it generates. The function stays active until done, but the user isnât waiting silent.
- Move work to background. Trigger an Edge Function or a queue (Inngest, QStash); respond to the user immediately; finish the work async.
- Add database indexes for slow queries.
Reference: Serverless functions đ©, Vercel đ© đŠ
âFunction invocation failed: Module âXâ not found at runtimeâ
What it means: The build succeeded (TypeScript / bundler resolved the import) but at runtime, the file isnât where the function expects.
Common causes:
- Native dependencies that arenât included in the deploy package (Sharp, sqlite3, others).
- Dynamic
require()calls the bundler couldnât trace. - External files (images, JSON) referenced via
fs.readFileSyncwithout including them in deploy. devDependenciesused in production code. Vercel strips dev deps; if your function imports one, it fails at runtime.
Fix:
- Move the dep into
dependencies(fromdevDependencies). - For external files: import them as ES modules (
import data from "./data.json") instead offs.readFile. Bundlers include imported files; fs references need explicit config. - For native deps: add to
serverExternalPackagesinnext.config.jsand ensure theyâre independencies.
âEdge Function: ReferenceError: process is not definedâ
What it means: Youâre using Node.js APIs (process.env, fs, path, Buffer) in code that runs on the Edge runtime. Edge functions use Web Platform APIs only.
Fix:
- Move to the Node.js runtime â at the top of the route file:
export const runtime = "nodejs"; // default; you only need this if previously set to edge - OR rewrite to use Web Platform APIs:
process.env.Xâ works in Edge for vars set in Vercel dashboard (since 2024) but not in all cases; checkfs.readFileâ not available; preload viaimportBufferâ useUint8Array/TextEncodercryptoâ useglobalThis.crypto.subtle
Reference: Edge functions đ©, Regions & edge đ©
âEdge Function: 1MB code size limit exceededâ
What it means: Edge functions ship to ~400 global locations; the bundle for each is capped.
Limits:
- Hobby: 1 MB
- Pro: 2 MB
- Enterprise: 4 MB
Fix:
- Move to the Node.js runtime if size constraints arenât workable.
- Lazy-load heavy modules with
await import()instead of top-level imports. - Audit dependencies â pick lighter alternatives (e.g.
date-fnsinstead ofmoment).
âFUNCTION_INVOCATION_TIMEOUTâ or âFUNCTION_INVOCATION_FAILEDâ
What they mean:
- TIMEOUT â same as âFunction execution timed outâ above.
- FAILED â generic. Read the actual logs; the underlying error is usually obvious there.
These appear as the response code on the request side; the actual stack trace is in Runtime Logs.
â504 Gateway Timeoutâ from your custom domain
What it means: Vercelâs edge couldnât get a response from your function within Vercelâs own timeout.
Common causes:
- Function took longer than the tier limit
- Function crashed silently
- Database connection hanging (Supabase down, network issue)
Fix: check the Runtime Logs for the function. The actual error will be there.
âBody exceeded 4.5 MBâ / âREQUEST_BODY_TOO_LARGEâ
What it means: A request body sent to a Vercel Function exceeded the platform limit.
Limits: 4.5 MB for Hobby; Pro can be configured higher.
Fix:
- For file uploads: use signed URLs (Supabase Storage, S3) and upload directly to storage from the browser. Donât proxy uploads through your function.
- For large JSON payloads: chunk them, paginate them, or compress (gzip).
âResponse body exceeded N MBâ
What it means: Your function returned a body larger than the limit (~4.5 MB for Hobby).
Fix:
- Stream the response â for large payloads, send chunks as you generate them.
- Paginate â return a page, with a cursor for the next.
- Compress â gzip the response (Next.js handles this automatically for most cases).
âTypeError: fetch failedâ or âECONNREFUSEDâ in production
What they mean: Your function tried to call an external service that wasnât reachable.
Common causes:
- Wrong URL (env var not set / incorrect / pointing at localhost in production).
- External service down or rate-limiting.
- CORS / firewall blocking the request.
- DNS resolution failure.
Fix:
- Check env vars in Vercel dashboard.
localhost:3000doesnât exist on Vercel. - Add retries with backoff for flaky third-party services.
- Log the URL to verify whatâs actually being called.
âMIDDLEWARE_INVOCATION_FAILEDâ
What it means: Your Next.js middleware (middleware.ts) threw or returned something invalid.
Common causes:
- Throwing without catching
- Calling Node.js APIs (middleware runs on the Edge runtime, same constraints)
- Returning a malformed
NextResponse
Fix: wrap middleware logic in try/catch; verify Edge-runtime compatibility; return NextResponse.next() for the default pass-through case.
âCannot find name âselfâ or âWebSocketâ in Edge functionâ
What it means: Type definitions for the Edge runtime arenât included.
Fix: in tsconfig.json:
{
"compilerOptions": {
"types": ["node"],
"lib": ["ES2022", "WebWorker", "DOM"]
}
}The WebWorker lib includes Edge-runtime globals.
âBuild deployed to a different region than expectedâ
What it means: You configured regions: ["syd1"] in vercel.json but functions are deploying to iad1.
Common causes:
vercel.jsonnot committed / not in the deployed branch- Misconfigured (e.g.
regioninstead ofregions) - Free tier limits â some region configurations require Pro
Fix: verify the deployed vercel.json. Check the function detail page on Vercel dashboard â it shows the region the function is actually pinned to.
Bible Quest pins to syd1 via vercel.json to match the Supabase project region; this avoids ~150ms latency on every database query.
âStatic page generation failed at runtimeâ
What it means: A page configured for ISR (Incremental Static Regeneration) failed to regenerate.
Common causes:
- Data source temporarily unavailable
- Type error introduced in a recent deploy that only fires during regeneration
- Database query timed out
Fix: check Runtime Logs for the specific page during the regeneration attempt. Fix the underlying issue; ISR will retry on the next request.
âVercel Analytics: events not being recordedâ
What it means: Vercel Analytics package is installed but events arenât showing in the dashboard.
Common causes:
- Analytics not enabled in dashboard for the project
- Free tier limits / sampling
@vercel/analyticspackage version mismatch with Next.js- Browser extension blocking the analytics endpoint (ad blockers)
Fix: verify the package version matches your Next.js version, enable analytics in the dashboard, test in a clean incognito window.
See also
- Common errors â index đ©
- Build errors đ© â for
npm run build/ deploy failures - Supabase errors đ© đŠ â if the runtime error is a Supabase query
- Browser errors đ© â for client-side issues
- Vercel đ© đŠ â the textbook
- Serverless functions đ©
- Edge functions đ©
- Regions & edge đ©
- How-to: Debug a Vercel build failure đ©
- Vercel CLI cheat sheet đ© đŠ