🔧 Error Fixes
· 1 min read

Vercel: Serverless Function Timeout — How to Fix It


FUNCTION_INVOCATION_TIMEOUT

Your Vercel serverless function exceeded the time limit (10s free, 60s pro).

Fix 1: Optimize the function

// ❌ Doing too much in one function
export async function GET() {
  const data = await heavyComputation();
  const processed = await processAll(data);
  await saveToDb(processed);
  return Response.json(processed);
}

// ✅ Break into smaller operations
export async function GET() {
  const data = await getCachedData();
  return Response.json(data);
}

Fix 2: Increase timeout (Pro plan)

// vercel.json
{
  "functions": {
    "api/heavy.ts": {
      "maxDuration": 60
    }
  }
}

Fix 3: Use background jobs

For long-running tasks, use a queue (Inngest, Trigger.dev, QStash) instead of doing everything in the request.