Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vercel: Exceeding size limits (50mb) for Serverless Function api/og #23

Closed
denull0 opened this issue Jan 3, 2022 · 3 comments
Closed
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@denull0
Copy link

denull0 commented Jan 3, 2022

Hey!

I have this in production on Vercel, and I get built errors now that there are more than 100 pages.

Error: The Serverless Function "api/og" is 56.39mb which exceeds the maximum size limit of 50mb. Learn More: https://vercel.link/serverless-function-size

@neg4n neg4n self-assigned this Jan 4, 2022
@neg4n neg4n added bug Something isn't working question Further information is requested labels Jan 4, 2022
@neg4n
Copy link
Owner

neg4n commented Jan 4, 2022

Hey @dimoFeeld! Thanks for reporting it. I'll inspect this in a detailed way soon 😇

@denull0
Copy link
Author

denull0 commented Jan 8, 2022

Hey @neg4n, I figured it out. So the problem is that AWS has a 50MB limit on Serverless functions. By adding more libraries on the server side, it passed the hard limit. My solution was to move the OG generation as a separate app, so I call it from https://og.domain.com/api/og

Hope this helps people who also stumble upon this issue

@denull0 denull0 closed this as completed Jan 8, 2022
@transitive-bullshit
Copy link
Contributor

I ran into this as well. Some steps for others to help debug the issue:

  • ensure tree shaking is working properly and make sure your serverless function imports are as minimal as possible
  • ensure large third-party libraries have "sideEffects": false in their package.json (otherwise vercel's bundler may be forced to include them in your lambda even if they're not used)

Even with these changes, the serverless function size is really close to the Vercel / AWS limit at 49.7MB. If this is the case for you, then consider downgrading to an earlier version of chrome-aws-lambda, some of which are much smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants