You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a copy of a troubleshooting article on Supabase's docs site. It may be missing some details from the original. View the original article.
The maximum size of a deployed Edge Function depends on how it's bundled:
Local bundling (Supabase CLI): up to 20 MB. The CLI bundles your function and its dependencies on your machine before uploading.
Server-side bundling (Management API or Dashboard): up to 5 MB. When you deploy without local bundling, bundling runs on the server, which has a lower infrastructure limit.
If your function exceeds the applicable limit, deployment fails with an error such as Function source code exceeds the maximum deployment size.
Check your bundle size
Use the deno info command to analyze your function's dependencies and total size:
deno info /path/to/function/index.ts
Look for the "size" field in the output to see the total bundle size.
How to reduce bundle size
If your bundle is too large, try these strategies:
Remove unused dependencies
Review your imports and remove any packages you're not actively using.
Use selective imports
Instead of importing entire packages, import only the specific modules you need:
// Good: Import specific submodulesimport{specific}from'npm:package/specific'// Avoid: Import entire packageimport*aseverythingfrom'npm:package'
Split large functions
Consider breaking large functions into smaller, more focused functions. Each function can handle a specific task, reducing the code needed in any single deployment.
Choose lightweight alternatives
Research smaller packages that provide the same functionality. Many NPM packages designed for Node.js include unnecessary polyfills that increase bundle size.
Deploying larger functions
If your function is under 20 MB but exceeds the 5 MB server-side limit, bundle it locally with the Supabase CLI to get the higher limit. Run supabase functions deploy with the --use-docker flag to force local bundling.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a copy of a troubleshooting article on Supabase's docs site. It may be missing some details from the original. View the original article.
The maximum size of a deployed Edge Function depends on how it's bundled:
If your function exceeds the applicable limit, deployment fails with an error such as
Function source code exceeds the maximum deployment size.Check your bundle size
Use the
deno infocommand to analyze your function's dependencies and total size:Look for the "size" field in the output to see the total bundle size.
How to reduce bundle size
If your bundle is too large, try these strategies:
Remove unused dependencies
Review your imports and remove any packages you're not actively using.
Use selective imports
Instead of importing entire packages, import only the specific modules you need:
Split large functions
Consider breaking large functions into smaller, more focused functions. Each function can handle a specific task, reducing the code needed in any single deployment.
Choose lightweight alternatives
Research smaller packages that provide the same functionality. Many NPM packages designed for Node.js include unnecessary polyfills that increase bundle size.
Deploying larger functions
If your function is under 20 MB but exceeds the 5 MB server-side limit, bundle it locally with the Supabase CLI to get the higher limit. Run
supabase functions deploywith the--use-dockerflag to force local bundling.Additional resources
Beta Was this translation helpful? Give feedback.
All reactions