-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
esbuild Process Using 13+ GB of Memory #388
Comments
I'm having the same issue, I try to run esbuild in CICD with limited ram capacity and the process is just growing exponentially to death of course. Can we force esbuild to run under a certain amount of ram for production build? |
Setting |
Oh thank you so much men, it saved me a lot of pain 👍 and actually in my side the speed is not that much impacted. |
Thanks very much for the solution |
I believe I found the culprit. In the bundle.ts file, in the I changed the code in the following ways (I just patched it);
- const context = await pkg.context?.(options);
- let result = await context?.rebuild();
- if (!result) {
- result = await pkg.build(options);
- }
+ const result = await pkg.build?.(options);
...
- return { bundlePath, entry, result, context };
+ return { bundlePath, entry, result }; This took my esbuild memory usage from ~16gb to ~200mb. |
I was having the same problem, but even more dramatic (~80 Lambdas).
How can we get this into the real implementation? I'd upvote. |
I'd hazard a guess that there are competing concerns here in that the context is being returned so serverless-offline works faster with incremental rebuilds (I didn't test this since serverless-offline was so slow for me that I wrote my own implementation to do local testing). @juanito-caylent do you use serverless-offline with serverless-esbuild? If so, did the patch make a difference for that? |
Seeing the same behaviour. My solution in the meantime was to do packaging without this plugin, and use a custom esbuild script, inspired by https://adieuadieu.medium.com/using-esbuild-in-your-serverless-framework-project-13723db5e32a. It's not ideal, and I'll be glad to remove this if a solution is found |
@Joshuabaker2 which bundle.ts file are you referencing? is it https://github.com/floydspace/serverless-esbuild/blob/master/src/bundle.ts |
Yes that file @walterholohan , the return is on line 122. @taijuten did you try removing the import and moving it top-level instead? Perhaps that is also needed. |
Thanks @Joshuabaker2 , do you think we should raise a PR for this? As for large projects this can be a big issue when trying to run builds on CI especially if you are using cheap linux machines (such as Github actions ubuntu machines) |
I think it should be merged in, the confounding variable that I mentioned above would need some consideration though and since I don't actually use serverless-offline I'm not really in the position to evaluate it:
|
@floydspace what do you think? |
I'm seeing a similar issue here. I'm curious about what would prevent these changes from coming in? |
I'm on the same boat, experienced this problem a couple of times now, specially when making deploys with GitHub Actions and a moderate number of lambdas. The GitHub Action runner just gets killed out of the blue, via external signal. No error happens in the action for it to be stopped, it just gets killed. I'm assuming the problem here is that the bundling process is taking more resources that the action runner has. |
consistent memory leak while bundling @AWS-SDK v3 |
I had the same problem, by removing all the |
Describe the bug
The esbuild process is using a ridiculous amount of memory. Our backend stack is relatively small, less than two dozen endpoints.
To Reproduce
Serverless Config:
Expected behavior
Not 15 GB worth of memory for a build.
Screenshots or Logs
Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: