The function ran longer than its allowed execution duration and Vercel returned a 504. Current ceilings range from 300 seconds to an eligible opt-in 1,800 seconds (30 minutes), but the route's configured value may be lower.
Why does this error happen?
- A database or API dependency responded too slowly.
- The function never returned an HTTP response.
- An infinite loop or unhandled path kept the invocation open.
How do you diagnose it?
- Check runtime, plan, Fluid compute status, and maxDuration.
- Inspect function logs for slow calls, exceptions, and the request ID.
- Add timing around upstream calls without logging secrets or request bodies.
How do you fix it?
- Return an HTTP response on every path.
- Add bounded upstream timeouts and parallelize independent I/O safely.
- Move resumable long work to a queue or workflow instead of keeping the HTTP request open.
How do you prevent it from recurring?
Turn the confirmed cause of FUNCTION_INVOCATION_TIMEOUT into an observable boundary for Vercel. Track the relevant request count, token volume, payload size, execution time, connection pressure, billing state, or upstream health before it reaches the documented failure condition. Preserve the platform request ID and timestamp so future incidents can be correlated without logging sensitive payloads.
Test the fix under representative concurrency and failure injection, not only with one successful request. Alert on remaining headroom and repeated retries, and keep the linked limit page and official error source with the runbook so responders can distinguish a configuration problem from temporary service pressure or account state.