GUIDES · RUNTIME DIAGNOSIS

FUNCTION_INVOCATION_FAILED on Vercel: debug the runtime crash

Vercel build is Ready but a serverless endpoint returns 500 FUNCTION_INVOCATION_FAILED. Find the real error in runtime logs and isolate the failing request.

A green build does not mean the function can run

Vercel can build and deploy an endpoint even if its first request throws, cannot connect to a database, or loads a missing runtime secret. A response mentioning FUNCTION_INVOCATION_FAILED means execution failed; it is not fixed by adding a catch-all rewrite to vercel.json.

Identify one failing path and the exact time of the request. If only /api/checkout fails, diagnose that function rather than rebuilding the entire site.

Read the runtime logs, not only the build logs

Open the deployment's Runtime Logs in Vercel, filter to the failing route and time, and inspect the stack trace. Build logs can be perfectly clean even when the runtime throws.

Reproduce the request with safe, non-secret test data. A 500 without an exception message in the browser does not mean the server has no useful log output.

Common triggers

Missing environment variables are common, especially values configured for Production but not Preview. Other causes include database connection errors, calling Node-only APIs from an Edge runtime, a missing native module, request-body parsing failures, and unhandled promise rejections.

Confirm the runtime (Node versus Edge), the environment scope, and whether the failing code path relies on network services. Avoid logging secret values, authentication tokens or personal request bodies.

Fix and verify one route

Add controlled error handling where it clarifies the failure, correct the underlying missing dependency or configuration, redeploy, then reissue the request and verify a successful response plus clean logs. Do not just swallow exceptions and return 200.

DeployDoctor's log diagnosis can help interpret build and deployment errors, but it cannot prove that a production database or private upstream service is healthy.

Updated 2026-10-21