Next.js Discord

Discord Forum

Serverless Function has exceeded the unzipped maximum size of 250 MB

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
hello, I can't publish my app to vercel
Error: A Serverless Function has exceeded the unzipped maximum size of 250 MB. : https://vercel.link/serverless-function-size

my code: https://github.com/th11n/uptube (i use nextauth, googleapis shadcn as external libraries)
what can i do? my build weights 380mb i tried setting max memory cache to 0 but it only decreased from 500mb to 380mb
Answered by linesofcode
try installing just the google apis you're using
View full answer

14 Replies

West African LionOP
b
Toyger
you can use bundle analyzer https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer to detect where is your biggest size packages and try to use something different if possible.
Or instead vercel you can host site on your own where you'll not have this limitations.
Toyger
it's not only this size, your main problem is googleapis, it make huge webpack file because it include everything in it, and for some reason unminified here is possible way to reduce it's size https://stackoverflow.com/a/73975868/2590591
25mb is huge
try installing just the google apis you're using
Answer
even if you get the size down to like 20mb, you're going to have a hefty cold-start time for the lambda
(it may even timeout if you're not on the pro plan)
@linesofcode try installing just the google apis you're using
West African LionOP
did it
from 530mb now i have 70mb
@Toyger you can use bundle analyzer https://nextjs.org/docs/app/building-your-application/optimizing/bundle-analyzer to detect where is your biggest size packages and try to use something different if possible. Or instead vercel you can host site on your own where you'll not have this limitations.
Northeast Congo Lion
Does this not work with the new "app" version of next.js? It is not working for me. I have a .mjs config file. I don't see anywhere that it shows how to use it for this.
@Northeast Congo Lion Does this not work with the new "app" version of next.js? It is not working for me. I have a .mjs config file. I don't see anywhere that it shows how to use it for this.
Toyger
it works a bit different, instead require you need to use import, something like https://github.com/vercel/next.js/discussions/30770
but it works only for client side bundle.
so before it you can just build your nextjs and check built .next folder with software like SpaceSniffer to check where is most size is occupied, if it in .pack files for server you can open them with vscode and check what they have in it.