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.
Cause: Uncaught exception, unhandled promise rejection, or a crashed runtime.
How to fix it
- Open the deployment's Logs tab and find the stack trace.
- Check production env vars are set (a missing one often throws at import time).
- Wrap handler logic in try/catch and return a proper error response.
- 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.
Get a $149 diagnosis See pricing Launching soon? The Launch Path gets you ready for $1,195 flat.
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- read-only access; fixes arrive as pull requests you merge
- Your $149 diagnosis is credited in full toward any paid job.