Skip to content
Latchkey

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.

Vercel
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/overview

Common 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

  1. Find the largest imports in the edge function or middleware.
  2. Import only the specific helpers you use rather than whole packages.
  3. 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.

app/route.ts
// 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.

Frequently asked questions

What causes ""Edge Function exceeds the maximum size""?
Middleware or an edge route imports a large library. Unlike serverless functions, the whole edge bundle counts against the per-function size cap.
How do I fix "Edge Function exceeds the maximum size"?
Trim what the edge bundle imports

Related guides

References

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