Skip to content
Latchkey

Vercel "Function Payload Size exceeds" limit in CI

Vercel bundles each Serverless Function with its dependencies, and the unzipped bundle exceeds the platform size limit (250 MB uncompressed). The deploy fails so the function is never published.

What this error means

A deploy fails with "Error: The Serverless Function \"api/x\" is 264.12 MB which exceeds the maximum size limit of 250 MB."

Vercel
Error: The Serverless Function "api/index" is 264.12MB which exceeds the maximum size limit of 250MB.

Common causes

Large dependencies bundled into the function

Heavy packages (headless browsers, ML libraries, large native binaries) get included in the bundle and push it past the limit.

Unneeded files traced into the bundle

The dependency tracer pulls in extra files (test data, source maps, multiple platform binaries) that inflate the function size.

How to fix it

Trim the bundle with includeFiles/excludeFiles

  1. Identify the largest dependency contributing to the bundle.
  2. Replace it with a lighter alternative or load it externally.
  3. Use functions config to exclude files the function does not need.
vercel.json
// vercel.json
{
  "functions": {
    "api/index.js": { "excludeFiles": "node_modules/**/test/**" }
  }
}

Move heavy work out of the function

Offload large binaries to external services or storage instead of bundling them into the function payload.

How to prevent it

  • Keep function dependencies minimal and platform-specific.
  • Exclude test fixtures and source maps from the bundle.
  • Watch bundle size in CI so growth is caught before deploy.

Frequently asked questions

What causes "Vercel "Function Payload Size ... exceeds""?
Heavy packages (headless browsers, ML libraries, large native binaries) get included in the bundle and push it past the limit.
How do I fix Vercel "Function Payload Size ... exceeds"?
Trim the bundle with includeFiles/excludeFiles

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card