Skip to content

Edge functions undocumented 4MB limit? #5076

@MT-AI-creator

Description

@MT-AI-creator

Hi! Hitting a deploy issue I’d love some clarity on.

Project: cmrhpmvjmbhzlpfhqzgw
Function: generate-lesson (also generate-practice)
CLI: supabase 2.84.2, --no-verify-jwt
Crash report ID from previous attempt: dd8a0bfc6d614eb1b594c8466f8e3bd2

Symptom: deploy returns HTTP 500 "Function deploy failed due to an internal error" after all assets upload successfully. No 4xx, no parse error — just an opaque 500. ~80+ retries over ~6 hours, identical result.
Other functions in the same project deploy fine.

Empirical investigation:

  1. The trigger correlation is with one shared module (exercise-generators.ts) crossing ~4 MB. Below ~3.85 MB → deploys work. Above ~4 MB → 500.
  2. Splitting the 4 MB module into multiple files of the same total bytes does NOT help — total bundle bytes seem to be what matters, not per-file.
  3. Stripping ~450 KB of comments from the module brings bundle back under threshold and deploys succeed.
  4. Smaller sister functions in the same project deploy fine because their transitive import graph is smaller.
  5. A minimal entry (216 bytes) that imports the same 4 MB module DOES deploy. So the limit appears to be entry-file complexity × shared graph, not just total bytes.

Questions:

  1. Is there a documented (or undocumented) bundle size limit for Edge Functions? The 20 MB figure in docs doesn’t match what we observe.
  2. Why a 500 instead of a clear 4xx "bundle too large"? The opaque 500 cost us ~6 hours of bisecting before we figured out the real threshold.
  3. Any chance of raising the limit, or guidance on the real-world ceiling so we can plan around it? We’re a Czech edu app generating 200+ exercise types server-side and growing fast.
  4. Is dynamic import (runtime-resolved path) supported on Supabase Edge Functions? If yes that would unlock per-task-type lazy loading.

Happy to share more details / repro privately. Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions