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

Next.js 13 Amplify - CustomerError: The size of the build output exceeds the max allowed size of 230686720 bytes #3647

Closed
4 tasks done
karloespiritu opened this issue Aug 15, 2023 · 10 comments
Assignees
Labels
archived This issue has been locked. compute question Further information is requested transferred This issue was transferred from another Amplify project

Comments

@karloespiritu
Copy link

Before opening, please confirm:

App Id

d2moft81gtdgs7

Region

us-west-2

Environment name

Frontend builds

Figma File Version (if applicable)

No response

Amplify CLI Version

No response

If applicable, what version of Node.js are you using?

18.13

What operating system are you using?

Mac

Browser type?

Chrome

Describe the bug

CustomerError: The size of the build output (264015647) exceeds the max allowed size of 230686720 bytes. Please reduce the size of your build output and try again.

I'm aware that Amplify has a limit of 200MB build output size for Next.js 12 and 13 apps. But our application is big and the 200MB limit is just too small for any large application. Many large-scale apps built with Next.js exceed the 200MB build output as demonstrated by other users who reported the same issue.

We already followed the build step command in the Amplify docs on how to reduce the build output size, but the size reduction is not enough to reduce the build output to less than 200MB.

du -h -d1 public:

12K public/js
128K public/favicon
3.2M public/img
48K public/sounds
120K public/json
4.0K public/maintenance
3.6M public

du -h -d1 .next/static:

636K .next/static/css
12M .next/static/chunks
28K .next/static/puGf1Ftyu3ImEPqhcvPhF
264K .next/static/media
13M .next/static

du -h -d1 .next/server:

5.1M .next/server/chunks
62M .next/server/pages
67M .next/server

Expected behavior

Build runs successfully.

Reproduction steps

Run build, then await for build to complete.

Project Identifier

No response

Additional information

Screenshot 2023-08-15 at 8 02 08 PM

@ykethan
Copy link
Member

ykethan commented Aug 15, 2023

hey,👋 thanks for raising this! I'm going to transfer this over to our hosting repository for better assistance 🙂.

@ykethan ykethan transferred this issue from aws-amplify/amplify-studio Aug 15, 2023
@ykethan ykethan added the transferred This issue was transferred from another Amplify project label Aug 15, 2023
@Jay2113 Jay2113 self-assigned this Aug 17, 2023
@Jay2113
Copy link
Contributor

Jay2113 commented Aug 22, 2023

Hi @karloespiritu 👋 , thanks for sharing the detailed information about the issue you are experiencing while deploying your Next.js application using Amplify Hosting.

Unfortunately, the 200 MB build output size is a hard limitation at the moment. Generally, our recommendation to reduce the build output size is as follows:

Based on the size of the files in your .next/server directory, it seems that your Next.js application has a large amount of pages and thus it is resulting in this deployment error. A potential workaround that you can consider is to use dynamic routes within your Next.js application as it will reduce the overall number of pages and in turn the build output size.

@Jay2113 Jay2113 added compute question Further information is requested response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed pending-triage labels Aug 22, 2023
@github-actions
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Aug 25, 2023
@karloespiritu
Copy link
Author

karloespiritu commented Aug 25, 2023

Hi @Jay2113 We already tried the 2 solutions you suggested, but the size reduction is insignificant to avoid reaching the 200MB limit. The 'dynamic routes' option is also not viable for our use case, as our application has a multitude of unique page routes that are indeed essential.

The 200MB limit is just too small to be hard limit for any modern large-scale Next.js app. A lot of other users of Amplify also experienced the same issue. Here are some examples:

Is there any plan any time soon to increase the maximum bundle size limit for Amplify? If not, which AWS service can be used to host a large Next.js 13 application instead?

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Aug 25, 2023
@pachoclo
Copy link

+1
Having the same issue on a relatively small project after adding Sentry.

@victorccccc
Copy link
Contributor

Hi 👋, we recently made the improvement and resolved this issue, please rebuild your application. Feel free to open the new issue if it persists. Thanks

Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

@pachoclo
Copy link

Hi 👋, we recently made the improvement and resolved this issue, please rebuild your application. Feel free to open the new issue if it persists. Thanks

@victorccccc Could you confirm when the improvement was made and what the improvement is? We saw this limit just last week.

Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Dec 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2023
@mauerbac
Copy link
Member

hi @pachoclo - this improvement was pushed out today. The team added logic to remove unnecessary packages for production that are typically large. Can you give it another try and let us know?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. compute question Further information is requested transferred This issue was transferred from another Amplify project
Projects
None yet
Development

No branches or pull requests

6 participants