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."
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
- Identify the largest dependency contributing to the bundle.
- Replace it with a lighter alternative or load it externally.
- Use
functionsconfig to exclude files the function does not need.
// 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.