-
-
Notifications
You must be signed in to change notification settings - Fork 463
RequestEntityTooLargeException: Request must be smaller than 69905067 bytes for the CreateFunction operation #236
Comments
I am slightly terrified of my Next.js app growing to the point where it exceeds the max direct upload size. I bought this theme and rolled it out to serverless as my first test of serverless and got a similar error. Perhaps we can have a flag that enables deployment using the s3 zip method which has a higher size? |
@jschimmoeller could you provide what is inside your |
@danielcondemarin ok as you will know there are 2 directories in this folder. api-lambda - pages/api - i have 52 items with the average size 6.9MB default-lambda - pages - i have 23 items with the average size 8.2MB also if i zip up these directories the sizes are |
There is a lot of duplication across all page bundles when building using the next serverless target. There should be a way to output the common chunks across page bundles in a separate file which would greatly reduce the lambda artifact size. That would involve going deep into the webpack config that next implements for the serverless target though. |
Related side note...I noticed an issue open that next.js serverless doesn't enable treeshaking: Seems strange to me given all the focus and performance improvements lately Next seems to be putting into serverless but perhaps it is true? Would something like this have any positive effect? |
Tried this plugin, didn't help |
If you put this in your webpack config, it might help as a workaround until treeshaking is fixed in Next.js serverless (vercel/next.js#8956)
(Note that this might increase build time so you would want to make this only happen during production build...probably using using phases.) |
If anybody is facing this issue has opted out of Automatic Static Optimisation in |
Great advice! With the next component you can have an indefinite number of static pages as they’re stored in S3. On the other hand, SSR pages are zipped up and used in lambda@edge so the lambda artifact size limit applies there. |
thanks for the recommendation; i did try both and each still failed.
` C:\Users\james\projects\new-refiner>serverless error: 491s » nextApp » Error: Command failed with exit code 1 (Unknown system error -1): node_modules/.bin/next build
` error: 94s » nextApp » RequestEntityTooLargeException: Request must be smaller than 69905067 bytes for the CreateFunction operation C:\Users\james\projects\new-refiner> |
I have tried modifying webpack config to,
and this worked, But what i want config is
this starts to gives error RequestEntityTooLargeException. |
FYI - Next.js recently added a new build target called "serverless trace". I haven't had time to look into it properly but looks like it would solve this issue. vercel/next.js#8246 If someone has time to do some initial investigations that would be much appreciated 🙏 |
I do think that serverless trace could make all serverless-next pages load faster because everything would be so much smaller |
I am very keen on getting this working. It would not just solve this particular issue with the size of the deployment artefact but also speed up deployments considerably. In terms of page load I don't think there will be much (if any) improvements as this only affects server side artefact size. @Enalmada Have you tried using the serverless trace with this project? It may give us a rough idea of what needs to be done to support it. |
So I've been doing a bit of investigation around this already. The What this means is this project has to zip up the |
I tried passing |
I have got a working proof of concept using the approach I mentioned in my comment above. This is what Zeit NOW uses in their stack as well so I'm considering making |
I also got this error when I tried to deploy ~4000 pages website into AWS Lambda:
There are actually 30 - 40 serverless functions in our application. By page, I mean the different pages created by dynamic routes which only contiant |
The function size will increase depending on how many server side rendered pages you have. Unfortunately next's serverless target doesn't dedup common dependencies across page bundles, which is why they've introduced a new target, the |
@danielcondemarin OK, let me rephrase what I said: With serverless function, I mean: and with page, I mean:
If there are 500 posts in the database, I can deploy the website successfully. But if there are 4000 posts in the database then I get So I don't see any relation between |
@mertyildiran I understand now. They're all prerendered static pages. They should not end up in the lambda@edge artefact. |
@danielcondemarin there are no HTML files but in |
@danielcondemarin I think we should add a control like |
Good catch! You're right they shouldn't be there. This only became an issue after |
Hi folks 👋 Some good news, I've managed to get the new Ideally this will be tested with a large app. could I have some volunteers please? module.exports = {
target: "experimental-serverless-trace",
...
} # serverless.yml
yourApp:
component: [email protected]
... Don't be put off by the target being "experimental". This is actually what Now uses under the hood for serverless deployments. I've pretty much replicated the same the Reference PR: #405 |
@danielcondemarin Thank you for this awesome feature! I've tested PS.: I'm not sure if I should open separate issues, so I'll just report the said tweaks below. 1. next.config.js is not normalized 2. Next config dir is being used as the base path for 3. Wrong API Lambda referenced on CloudFront distribution |
I did some modification and its works for me. Please 🙏 review the PR and let me know, what do you think. |
sorry @thiagozf I didn't notice you already created PR for the same fix. |
@danielcondemarin I've submitted PR #425 that should fix both chunks and monorepo issues by using @krish-dev Hey! I think we were working at the same thing at the same time. |
@thiagozf @krish-dev Thank you both for the amazing contributions to this issue. I've now merged & published #425 in |
Thanks, @danielcondemarin for the new release. Works like a champ 👍 . great work @thiagozf 🙌 |
I just want to mention one observation. the deployment time highly increased. Previously my total lambda bundle size was around 50 MB (using |
Hey @krish-dev, sorry to hear that. My build time in a large(ish) app has increased some seconds, but the deploys are faster. Has this started after #425? By build generation, you mean the Serverless Component build or the Next.js build? Can you deploy your app with the |
It seems that It would be great if we can use serverless-plugin-monorepo. But anyway, thanks everyone's efforts! |
@kenberkeley Do you have a minimum repro? I was able to get it working in a monorepo setup. |
Only scoped packages are included in the |
@kenberkeley This is happening because the component uses @danielcondemarin Can we have the base path for |
Hey @thiagozf sorry for the delayed response. it's working perfectly, probably that day I had the internet connectivity issue, tested full process with BitBucket Pipeline and it increased few second only which is expected. |
Could we not follow symlinks to solve this instead? Similar to what |
@kenberkeley I had a look at your repo.zip example and an option could be to move |
@danielcondemarin I am having this similar issue with mono repo so I also tried to deploy from the root. However I get this error at the end:
Our serverless.yml looks like:
I also tried to understand what the destination looked like and it was:
Could you please help to understand what's happening here? |
@jaypeng2015 there is a separate thread on this: #461 (comment), I posted my findings. For me it was because it was somehow trying to copy my serverless-next.js/packages/libs/lambda-at-edge/src/build.ts Lines 112 to 116 in d0a6300
node_modules in the path.
|
I am trying out
Is there something obvious I might have done wrong or could try? |
In my example, I've found out the reason was because of yarn workspace.
If the package is in root node_modules and is required in /apps/web,
This piece of code returns '../../../../packages/foo/index.js', and then join with
It becomes So the root reason it that |
For me it's the package.json file in the source root folder. I have been able to deploy by using following steps;
I can't do this in CI/CD but at least this workaround helps me with urgent deployment needs for the time being. Not sure if it's creating other issues though. |
Using @sls-next/[email protected] with [email protected] by the way. |
I solved it by adding following to my CI/CD pipeline.
|
@danielcondemarin I've updated const withCSS = require('@zeit/next-css');
module.exports = withCSS({
webpack: function (config) {
config.module.rules.push({
test: /\.(eot|woff|woff2|ttf|svg|png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 100000,
name: '[name].[ext]'
}
}
});
return config;
},
target: 'experimental-serverless-trace'
});
However I still get error like title when run command |
I think long-running issue can be closed, the newest versions of Next.js + this component are now fairly optimized and you can also add minification to solve it if it is not enough. Please check the FAQs for related tips on this. |
Hey daniel,
I finally had some time to check the latest code against my large next.js project and I am get this error;
error:
RequestEntityTooLargeException: Request must be smaller than 69905067 bytes for the CreateFunction operation
at Object.extractError (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\protocol\json.js:51:27)
at Request.extractError (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\protocol\rest_json.js:55:8)
at Request.callListeners (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\sequential_executor.js:106:20)
at Request.emit (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\sequential_executor.js:78:10)
at Request.emit (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\request.js:683:14)
at Request.transition (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\request.js:22:10)
at AcceptorStateMachine.runTo (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\state_machine.js:14:12)
at C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\state_machine.js:26:10
at Request. (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\request.js:38:9)
at Request. (C:\Users\james.serverless\components\registry\npm\[email protected]\node_modules\serverless-next.js\node_modules\aws-sdk\lib\request.js:685:12) {
message: 'Request must be smaller than 69905067 bytes for the CreateFunction operation',
code: 'RequestEntityTooLargeException',
time: 2019-11-12T14:54:17.708Z,
requestId: '84af6699-36b9-4a2b-ab1c-88c468b47d19',
statusCode: 413,
retryable: false,
retryDelay: 86.11399872761147
}
135s » nextApp » RequestEntityTooLargeException: Request must be smaller than 69905067 bytes for the CreateFunction operation
The text was updated successfully, but these errors were encountered: