Partly fixable yourself. Raising a limit is quick, restructuring a job is not.
What you see. Long actions like AI generation, PDF export or imports fail with a 504 or FUNCTION_INVOCATION_TIMEOUT after a fixed number of seconds.
Why it happens
Server functions on hosting platforms have a time budget. On Vercel, functions default to 300 seconds, which is also the ceiling on Hobby, while Pro and Enterprise can raise it to 800 seconds. Vercel Edge runtime functions must start responding within 25 seconds. Netlify synchronous functions stop at 60 seconds and that cannot be changed, while background functions run up to 15 minutes. Supabase Edge Functions get 150 seconds on the Free plan, 400 on paid plans, 2 seconds of CPU time per request, and the caller gets a 504 if nothing is sent within 150 seconds.
The function usually hits the limit because it waits on something slow, an AI model, a big database query, or an external API. Vercel also lists a function that never returns a response, an endless loop, and an unhandled exception as common causes. Preview rarely shows this because you tested with small inputs.
Fix it yourself
- Find which function failed. The URL tells you:
/api/on Vercel,/.netlify/functions/on Netlify,/functions/v1/on Supabase. Open that host's logs and find the last line before the timeout. - Compare how long the step takes with the limit for your host and plan listed above. If you are close, the job needs a different shape, not a bigger number.
- On Vercel you can raise the budget within your plan with
export const maxDuration = 60in the route file, or afunctionsblock invercel.json. - Ask your builder: Put a timeout on every outbound call, catch errors, and always return a response, even an error one.
- For work that genuinely takes minutes, move it to a background job: a Netlify background function, Vercel Workflows, or a queue. The page starts the job, gets an id, and polls for the result.
- If the slow step is a database query, check that the columns you filter on have indexes. That is check COST-02.
When to get an engineer
Get an engineer when the job really needs minutes, because turning a request into a background job with status polling touches the database, the function, and the page. Tell them the host, the plan, the failing function, and a typical input size. A single fix is €99–$990 and takes two to five days. Ask them to add a progress state in the UI so users know the job is running.
Top-rated companies for Supabase apps
Ranked by our score: published prices, scope of work, AI tools named, timing and a low-risk first step. How we score.
- 1Redlab10.0/10Best for: A full rescue by one team that keeps buildingFree first step · from $490
- 2Vibe Code Rescue (Lev Arakelyan)9.0/10Best for: A one-off check and a cleanupFrom $299
- 3LazyCodeLab9.0/10Best for: A one-off check and a cleanupFrom $399
Check these
Database columns you filter on are indexed
Queries that scan whole tables are fast at 100 rows and slow at 100,000.
Errors reach you before users do
Add error monitoring and uptime alerts. If you learn about outages from customers, this is missing.
AI and paid API calls have per-user limits
Without a cap, one user or one bot loop can spend your monthly budget in an hour.
Input is validated on the server
Forms that only check input in the browser accept anything sent directly to the API.
Questions
Can I just raise the limit to the maximum?
On Vercel Pro up to 800 seconds, yes. On Hobby, Netlify synchronous functions and Supabase the limits are fixed. A longer wait also costs more and still fails if the upstream call hangs.
Why is only the live site affected?
Local development has no time limit, and preview tests use small inputs. Real users upload bigger files and ask longer questions.
Sources: Vercel: functions limits; Vercel: FUNCTION_INVOCATION_TIMEOUT; Netlify: functions configuration; Supabase: Edge Function limits.
