amplify-hosting
amplify-hosting copied to clipboard
CustomerError: The size of the build output (298151661) exceeds the max allowed size of230686720 bytes
Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the FAQ.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
App Id
d2tb5y9nn2b55z
AWS Region
us-east-1
Amplify Hosting feature
Deployments
Frontend framework
Next.js
Next.js version
13.3.0
Next.js router
N/A
Describe the bug
2023-12-05T21:02:30.784Z [ERROR]: !!! CustomerError: The size of the build output (298158428) exceeds the max allowed size of230686720 bytes. Please reduce the size ofyour build output and try again.
The size show above varies depending on any changes we have tried to make like the build image, node version etc. The .next folder is less than 60mb and public folder, after deleting some unnecessary images is less than 100mb in size. we are removing the folders standalone and cache from .next as well This bug started showing up after we added a new dependency ("fabric": "^5.3.0"). if we remove this dependency, the build goes through. this dependency is absolutely crucial to us so we cannot just remove it. we have tried multiple different ways like changing the build images from the default linux2 to linux3 and also using custom public:ecr images for node in different supported versions. we know that the size of the build output is not an issue because the sum total of public+.next folders is well less than 200mb after we delete all unnecessary files in the post build step. included the log entry that shows the size of these folders.
please refer to the failing builds in nest_next_web_testing app.
Expected behavior
deployment should be successful
Reproduction steps
no special steps needed. build fails.
Build Settings
version: 1
frontend:
phases:
preBuild:
commands:
- rm *.lock
- rm package-lock.json
- yarn install
- rm -r public/hdr
- rm public/assets/img/*.mp4
build:
commands:
- yarn run build
postBuild:
commands:
- pwd
- ls -lart *
- rm -r .next/standalone
- rm -r .next/cache
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Log output
# Put your logs below this line
2023-12-05T21:39:37.689Z [INFO]: # Executing command: rm -r .next/standalone
2023-12-05T21:39:37.954Z [INFO]: # Executing command: rm -r .next/cache
2023-12-05T21:39:37.997Z [INFO]: # Executing command: du -sh *
2023-12-05T21:39:38.000Z [INFO]: 4.0K README.md
4.0K amplify.sh
4.0K amplify.yml
4.0K next-env.d.ts
4.0K next-sitemap.config.js
4.0K next.config.js
2023-12-05T21:39:41.332Z [INFO]: 1.4G node_modules
4.0K package.json
2023-12-05T21:39:41.338Z [INFO]: 71M public
2023-12-05T21:39:41.352Z [INFO]: 16M src
4.0K tsconfig.json
456K yarn.lock
2023-12-05T21:39:41.354Z [INFO]: # Executing command: du -sh .next
2023-12-05T21:39:41.362Z [INFO]: 56M .next
2023-12-05T21:39:41.362Z [INFO]: # Completed phase: postBuild
2023-12-05T21:39:41.369Z [INFO]: ## Build completed successfully
2023-12-05T21:39:41.371Z [INFO]: # Starting caching...
2023-12-05T21:39:41.380Z [INFO]: # Creating cache artifact...
2023-12-05T21:41:05.882Z [INFO]: # Created cache artifact
2023-12-05T21:41:06.133Z [INFO]: # Uploading cache artifact...
2023-12-05T21:41:11.970Z [INFO]: # Uploaded cache artifact
2023-12-05T21:41:12.130Z [INFO]: # Caching completed
2023-12-05T21:41:12.137Z [INFO]: # No custom headers found.
2023-12-05T21:41:56.954Z [ERROR]: !!! CustomerError: The size of the build output (298151661) exceeds the max allowed size of230686720 bytes. Please reduce the size ofyour build output and try again.
2023-12-05T21:41:57.241Z [INFO]: # Starting environment caching...
2023-12-05T21:41:57.241Z [INFO]: # Environment caching completed
Terminating logging...
Additional information
No response
Also can someone from the Amplify team confirm exactly what goes into the "build output" folder and how the size is calculated? Can this be printed in the error message? This would save folks a lot of wasted hours.
I too have the same issue. This is a fresh nextjs 13 app with a basic implementation of an MUI dashboard layout as implemented in MUI's demos.
fyi for anyone else looking at this thread for updates, nothing from AWS, so we decided that amplify is a big waste of time :). we deployed our stack to EC2.
Also can someone from the Amplify team confirm exactly what goes into the "build output" folder and how the size is calculated? Can this be printed in the error message? This would save folks a lot of wasted hours.
Hi 👋 , sorry for the inconvenience. We added logic to remove unneeded dependency files that are typically large (e.g some unused heavy binaries under @esbuild
and @swc
packages).
To review your build output folder, you can:
- Run following command
aws amplify get-job --app-id ${APP_ID} --branch-name ${BRANCH_NAME} --job-id ${BUILD_ID}
- Find
artifactsUrl
(presigned S3 url) under job -> steps -> stepName: "BUILD" - Download the file which is your build output.
The bundle size issue could happen if your app has heavy dependencies. You can check size of the dependency under the node_modules
folder in the build output. You could try to use a lighter weight dependency or remove some of the files you wouldn't need.
@victorccccc This has become a big issue now.. Any solution to remove this limit? Now we are not able to release any new content.
Now we've to move to some other solution because of this illogical limit. This business breaking limit should be removed ASAP. For us there is too much cost to move out of AWS and there is deadlock.
Please help us understand why this limit is there anyways?
Any update on this issue?
In my case what I had to do It's to upgrade to Nextjs 14, and then in the build image settings, update the build image to Amazon Linux:2023. I hope this could be helpful for you.
@gzManuel Are you sure? AWS Support told that this 200MB limit is due to Lambda restriction internally and it can not be changed as of now.
@gzManuel Are you sure? AWS Support told that this 200MB limit is due to Lambda restriction internally and it can not be changed as of now.
Now that you are saying that changing to Next 14 reduced my build output to less than 200MB, I think that's the reason It was able to deploy it. In the oficial documentation says that Next 12 and 13 have the limitation of 200MB but it doesn't mention Next 14. resource
Hi everyone 👋 , we have updated our documentation with the following troubleshooting guide: https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html#build-output-too-large. This guide should enable you to:
- Download and inspect your build artifacts
- Analyze the
.next
directory and the buildcache
directory within it - Measure the size of your
compute
andstatic
directories - Review the dependencies within the
node_modules
folder - Delete the binaries that aren't required at runtime
Additionally, to improve build performance and to persist the cache between builds Amplify Hosting now adds the following cache paths by default to your buildSpec
:
cache:
paths:
- node_modules/**/* # Cache `node_modules` for faster `yarn` or `npm i`
- .next/cache/**/* # Cache Next.js for faster application rebuilds
This issue is now closed. 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.
This issue has been automatically locked.