Vercel "Edge Function ... exceeds the maximum size" in CI
Vercel Edge Functions have a compressed code-size limit per function (1 MB on Hobby, larger on paid plans). When a function bundles more than that, the build fails before the deploy completes.
What this error means
The Vercel build fails with "The Edge Function \"<name>\" is X MB which exceeds the maximum size limit of Y MB." The function imports more than the edge bundle can hold.
Error: The Edge Function "middleware" size is 1.6 MB and your plan size limit
is 1 MB. Learn More: https://vercel.com/docs/concepts/limits/overviewCommon causes
A heavy import pulled into an edge bundle
Middleware or an edge route imports a large library. Unlike serverless functions, the whole edge bundle counts against the per-function size cap.
A function that should run on the Node runtime
Code that needs large dependencies is forced onto the Edge runtime by a runtime export, when it would fit comfortably as a Node serverless function.
How to fix it
Trim what the edge bundle imports
- Find the largest imports in the edge function or middleware.
- Import only the specific helpers you use rather than whole packages.
- Move logic that needs heavy dependencies out of the edge path.
Move the route to the Node runtime
If the code does not need the Edge runtime, drop the edge runtime export so it deploys as a Node serverless function with a larger size budget.
// remove this to use the default Node runtime
export const runtime = 'edge';How to prevent it
- Keep middleware and edge routes lean; route heavy work to Node functions.
- Audit edge imports for large dependencies before deploying.
- Reserve the Edge runtime for latency-sensitive, small-bundle logic.