Error library

Vercel FUNCTION_INVOCATION_FAILED (500)

Vercel returns FUNCTION_INVOCATION_FAILED (500) when the runtime crashes or the code throws an unhandled exception or rejection. Check the function logs for the real error, often a missing env var in production.

Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis

Cause: Uncaught exception, unhandled promise rejection, or a crashed runtime.

How to fix it

  1. Open the deployment's Logs tab and find the stack trace.
  2. Check production env vars are set (a missing one often throws at import time).
  3. Wrap handler logic in try/catch and return a proper error response.
  4. Reproduce locally with production env values.

Example

Illustrative example, not from a customer project.

- const client = new Stripe(process.env.STRIPE_SECRET_KEY!)
+ if (!process.env.STRIPE_SECRET_KEY) throw new Error('STRIPE_SECRET_KEY not set')
+ const client = new Stripe(process.env.STRIPE_SECRET_KEY)

FAQ

It works locally.

Production often lacks an env var or has a different runtime; check the logs.

Where are the logs?

In the Vercel dashboard under the deployment's Logs.

QUICK FIX · $49 · THIS ERROR ONLY

Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis

One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.

Bigger job: Getting the whole app live? Launch Path, $1,195 flat.

Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.

Check it yourself first, free

$49Fix this error