Build Failed: build exceeded memory limit and was terminated

I tried the same by increasing --max-old-space-size=8192 but deployment continued to have the same error as stated. |14:08:46.399|Success: Finished cloning repository files| |14:18:58.679|Failed: build exceeded memory limit and was terminated| Deployment id: 9aff3dcd-9f38-4002-93db-5020409e5a8b node: 18.17 Would appreciate any help. It's quite urgent.
76 Replies
Vero
Veroβ€’6mo ago
Hey, here are some things that may help: - Reduce concurrency settings in your build (if applicable.) Eg. next.js defaults to 7 threads that can be overridden by specifying experimental.cpus: 4. - Reduce Node memory by specifying an environment variable: NODE_OPTIONS=--max-old-space-size=3072 (if you’re setting this elsewhere already, then change it there instead.) Please let me know if this doesn't fix the issue
Rishabh
RishabhOPβ€’6mo ago
@Vero πŸ™ I have added experimental.cpus: 4 in next.js config. Also added NODE_OPTIONS=--max-old-space-size=3072 in env Error occured while creating build: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory Failed: Error while executing user command. Exited with error code: 1 Failed: build command exited with code: 1 Failed: error occurred while running build command Still not resolving the issue ?? @Vero πŸ™ After that i increased this NODE_OPTIONS=--max-old-space-size=3072 to NODE_OPTIONS=--max-old-space-size=7620 Error occured: 10:48:16.537 Failed: build exceeded memory limit and was terminated Could you please suggest something else which i can try to resolve this issue @Vero πŸ™ can you please suggest something
Vero
Veroβ€’6mo ago
you should actually decrease this, Pages builds get ~8GB of memory for building their projects
Rishabh
RishabhOPβ€’6mo ago
@Vero πŸ™ i have used 3072 but it is showing the above error which i mentioned. Can you suggest me what memory i can use ?? Or if you have any other approach to resolve this issue @Vero πŸ™ Can you please look on this issue?? Its quite urgent for me to resolve this issue
Vero
Veroβ€’6mo ago
Could you please send me your account ID?
Rishabh
RishabhOPβ€’6mo ago
@Vero πŸ™ Sure..!! This is my account Id 3e36494bda5757430bacf51c02628219 @Vero πŸ™ Please check it
Vero
Veroβ€’6mo ago
I actually need your pages zone, sorry, can you tell me which Pages zone specifically?
Amr Yasser
Amr Yasserβ€’6mo ago
same problem here, the local pages build works seamlessly but the deployment gives the above error
Vero
Veroβ€’6mo ago
Have you reduced the node memory already? also can you please tell me more about your use case, what kind of project are you building?
Amr Yasser
Amr Yasserβ€’6mo ago
yes, here is the error FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory I am trying to deploy a fullstack next.js app with D1 binding
Vero
Veroβ€’6mo ago
ok then can you also please send me your Pages zone?
Amr Yasser
Amr Yasserβ€’6mo ago
where can I find the zone?
Vero
Veroβ€’6mo ago
It should be under your Pages project in the overview. It's your pages domain, something like <YOUR_SITE>.pages.dev
Amr Yasser
Amr Yasserβ€’6mo ago
wodge.pages.dev
Vero
Veroβ€’6mo ago
Great, thanks. Can you please also share the ID of the deployment where you're getting this error?
Amr Yasser
Amr Yasserβ€’6mo ago
main 3e52559
Vero
Veroβ€’6mo ago
Can you please check again? deployment IDs are different. Usually you can find the ID after the error, something like this: |14:18:58.679|Failed: build exceeded memory limit and was terminated| Deployment id: 8sdh3ufu-1r83-2034-43db-7323742e5a7e
Amr Yasser
Amr Yasserβ€’6mo ago
can't find it here are the lines from the begining of the error <--- Last few GCs ---> 19:24:26.652 β–² 19:24:26.652 β–² [1093:0x573c3a0] 91729 ms: Scavenge (reduce) 3059.1 (3096.2) -> 3058.5 (3096.4) MB, 2.2 / 0.0 ms (average mu = 0.189, current mu = 0.004) allocation failure; 19:24:26.652 β–² [1093:0x573c3a0] 92446 ms: Mark-sweep (reduce) 3059.3 (3096.4) -> 3058.6 (3096.7) MB, 716.0 / 0.0 ms (average mu = 0.106, current mu = 0.018) allocation failure; scavenge might not succeed 19:24:26.652 β–² 19:24:26.652 β–² 19:24:26.652 β–² <--- JS stacktrace ---> 19:24:26.652 β–² 19:24:26.652 β–² FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 19:24:26.653 β–² 1: 0xb83f50 node::Abort() [node] 19:24:26.653 β–² 2: 0xa94834 [node] 19:24:26.654 β–² 3: 0xd647c0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node] 19:24:26.654 β–² 4: 0xd64b67 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node] 19:24:26.655 β–² 5: 0xf42265 [node] 19:24:26.656 β–² 6: 0xf43168 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node] 19:24:26.656 β–² 7: 0xf53673 [node] 19:24:26.657 β–² 8: 0xf544e8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 19:24:26.658 β–² 9: 0xf2ee4e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node] 19:24:26.658 β–² 10: 0xf30217 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node] 19:24:26.659 β–² 11: 0xf113ea v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node] 19:24:26.660 β–² 12: 0x12d674f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node] 19:24:26.661 β–² 13: 0x17035b9 [node] 19:24:26.877 β–² Aborted 19:24:26.880 β–² ELIFECYCLE  Command failed with exit code 134. 19:24:26.917 β–² Error: Command "pnpm run build" exited with 1 19:24:28.107 19:24:28.108 ⚑️ The Vercel build (pnpm dlx vercel build) command failed. For more details see the Vercel logs above. 19:24:28.108 ⚑️ If you need help solving the issue, refer to the Vercel or Next.js documentation or their repositories. 19:24:28.108 19:24:28.132  ELIFECYCLE  Command failed with exit code 1. 19:24:28.158 Failed: Error while executing user command. Exited with error code: 1 19:24:28.169 Failed: build command exited with code: 1 19:24:29.068 Failed: error occurred while running build command
Vero
Veroβ€’6mo ago
?pages-deployment-id
Flare
Flareβ€’6mo ago
The Pages deployment ID is a unique build identifier. It's the UUID in the browser bar (for example, a URL would be dash.cloudflare.com/ACCOUNT_ID/pages/view/PROJECT/DEPLOYMENT_ID where the deployment ID looks something like a398d794-7322-4c97-96d9-40b5140a8d9b). This ID can help troubleshoot some issues with Pages builds so if you have a failing build make sure you grab that ID for the team to use.
Vero
Veroβ€’6mo ago
You can find it in your URL ^
Amr Yasser
Amr Yasserβ€’6mo ago
here it is 31fa2d57-4948-4d7f-85b2-d11d890e6913
Vero
Veroβ€’6mo ago
Thanks, I've passed this internally Also passed yours @Rishabh Pachori but please tell me more about your use case when you can
Amr Yasser
Amr Yasserβ€’6mo ago
Thank you, do you have an estimate on how long will it take?
Vero
Veroβ€’6mo ago
No. Pages projects builds get 8GB of memory, we'll try to increase this for you, but this isn't something we usually do. Also, I've already ended my shift so don't expect a response today, will give you an update tomorrow πŸ™‚
Rishabh
RishabhOPβ€’6mo ago
@Vero I am trying to deploy a fullstack next.js app Account id : 3e36494bda5757430bacf51c02628219 Zone: zn1.pages.dev Deployment id: 9aff3dcd-9f38-4002-93db-5020409e5a8b Deployment Id: 3a48cf05-d691-4f2a-9c48-a8b3e3a9e271 node: 18.17 @Vero I am deploying a Next.js full stack application staging app in cloudflare. Soon in the next 2 -3 weeks i will deploy a production application too in cloudflare. This application conatins chat application, CRM management, Event management. So almost initially we got thousands of users who will be using it on daily basis after we launch it in production. I am afraid for this staging app you increase this limit this time. For production app i need to connect with you again for this issue ?? @Vero Any update for the above issue ??
Walshy
Walshyβ€’6mo ago
It was escalated to the team It's awaiting them, an update will be given when there is one
Rishabh
RishabhOPβ€’6mo ago
@Vero @Walshy | Deploying Do you have an estimate on how long will it take from your end?
Walshy
Walshyβ€’6mo ago
No, Eng team may take a day or may take a week. We don't know and all we can do is wait.
Amr Yasser
Amr Yasserβ€’6mo ago
sorry for repeatedly asking but it is critical, any updates?
Walshy
Walshyβ€’6mo ago
Still waiting on the Eng team It's the weekend now so they aren't working either @Vero can give them a nudge on Monday
Rishabh
RishabhOPβ€’5mo ago
@Vero πŸ™ any update for the same ??
Vero
Veroβ€’5mo ago
The team just created a PR for this but it's pending review This should be fixed now. Could you please try building you projects again? @Rishabh Pachori @Amr Yasser
Rishabh
RishabhOPβ€’5mo ago
Sure. I am checking it @Vero πŸ™ I have checked it. Its working now. I will be monitor it for 2 -3 days and will let you know if i get any issue. @Vero πŸ™ As i told you i will create one more project for production environment in the next week. is there any configuration i need to do at my end before deploying it that you have suggested to me in above message. Please let me know do i need to set NODE_OPTIONS at all ??? or set experimental cpus at all in next.js config. Thankyou for the help.πŸ˜€
Vero
Veroβ€’5mo ago
If you run into memory issues again (which is unlikely), you can add those flags again, but it's probably unnecessary to use those flags now
Amr Yasser
Amr Yasserβ€’5mo ago
still does not work form me FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory note that manual deployment works
Amr Yasser
Amr Yasserβ€’5mo ago
and the cpus are 4 in next.config.js
No description
No description
Vero
Veroβ€’5mo ago
can you please remove that flag? and check if it works
Amr Yasser
Amr Yasserβ€’5mo ago
it does not the deployment before this one was without the flag
Vero
Veroβ€’5mo ago
are you using this flag also: NODE_OPTIONS? It shouldn't be necessary anymore
Amr Yasser
Amr Yasserβ€’5mo ago
ok I will try without it It works now, thank you!
Vero
Veroβ€’5mo ago
awesome!
Amr Yasser
Amr Yasserβ€’5mo ago
Follow-up: it is not stable, now I tried a new deployment it does not work at first, and when I run a retry it worked 7b36de0d-0756-4026-b433-54452cd042aa deployment id Update: It is totally broken now 37a2403f-9c2e-49ec-9604-c7cf3cece27e @Vero πŸ™
Vero
Veroβ€’5mo ago
can you please try adding this flag again? NODE_OPTIONS=--max-old-space-size Lets try NODE_OPTIONS to--max-old-space-size=5120 first, then if that doesn't work, try increasing to NODE_OPTIONS to--max-old-space-size=8192
Amr Yasser
Amr Yasserβ€’5mo ago
I did , It is stable and working now
Vero
Veroβ€’5mo ago
Great
Rishabh
RishabhOPβ€’4mo ago
@Vero πŸ™ | Out of Office @Walshy | Deploying I recently got the error again in the same account here are the deployment ids Deployment Id bd5bb216-77a6-4286-be77-4278710f36da fcb1aecc-dac7-4b20-9bba-56d1ac7716ed @Vero or @Walshy could you please look into this issue?? My builds are failing again I tried with NODE_OPTIONS to--max-old-space-size=5120 as well but it still failed.
Vero
Veroβ€’4mo ago
Hi. What amount do you have in NODE_OPTIONS=--max-old-space-size ? Sorry, I didn't read your message completely
Rishabh
RishabhOPβ€’4mo ago
Hii @Vero πŸ™ @Walshy | Deploying Deployment Id: 819188b5-b89c-44ca-8ac4-8fcc49202305 d4a40a81-15f8-491a-8733-4ede153a55ab Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev NODE_OPTIONS=--max-old-space-size=7620 We are using this node options while building on this project.. Please fix this issue for this account as we are not able to make our builds in prod and preview environment. Please fix this as soon as possible. It will be very helpful
Vero
Veroβ€’4mo ago
hmmm that's a different zone right? Not the zone where you were having this issue previously
Rishabh
RishabhOPβ€’4mo ago
Yes I am getting the same issue again and again in the previous zone but today i deploy my project in this account and zone. Could you please help me @Vero πŸ™ to resolve this issue as soon as possible in this zone and account id Deployment Id: 819188b5-b89c-44ca-8ac4-8fcc49202305 d4a40a81-15f8-491a-8733-4ede153a55ab Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev @Vero πŸ™ do you get a time to look into this issue ??
Vero
Veroβ€’4mo ago
I see you've increased NODE_OPTIONS=--max-old-space-size, you should actually reduce it. You could try reducing it to 3072
Rishabh
RishabhOPβ€’4mo ago
@Vero πŸ™ Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev For this account and zone project as well. I have reduced it. But not resolving the issue Did you get a chance to look on it.
Vero
Veroβ€’4mo ago
Hey, this should be solved now, can you please check?
Rishabh
RishabhOPβ€’4mo ago
Okay
Rishabh
RishabhOPβ€’4mo ago
@Vero πŸ™ It is still not resolved. I tried to build again but getting same error. Deployment Id: 358a69b2-1b09-468f-af53-d7905daa747b Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev
No description
Rishabh
RishabhOPβ€’4mo ago
@Vero πŸ™ Could you please check with your team?? As it is causing issue on my end
Vero
Veroβ€’4mo ago
Hey. We've seen that you're giving Node too much memory, please reduce it to 3072. You're using too much memory and we've already raised your limit 2 times, we can't increase it more @Rishabh Pachori
Rishabh
RishabhOPβ€’4mo ago
@Vero | Out of Office In this account you did not increased two times for this account i asked you one time only @Walshy | Deploying could you please check if you can increase memory for this account Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev Deployment Id: 358a69b2-1b09-468f-af53-d7905daa747b For this account and zone project as well. its really urgent for me to resolve this issue
Walshy
Walshyβ€’4mo ago
I'll pass it onto the PM but I'd guess probably not this has also been said a few times, you're giving the parent node process 7.6 gb of memory and then that can spin up other ones which easily consume all the memory available. You should really just reduce your memory usage here.
Rishabh
RishabhOPβ€’4mo ago
yes please let me know okay How much memory i can use it in NODE_OPTIONS Can i try to use with this memory?? NODE_OPTIONS=--max-old-space-size=3072 Until then you can try if you can increased memory for this account Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev Deployment Id: 358a69b2-1b09-468f-af53-d7905daa747b
Walshy
Walshyβ€’4mo ago
yeah 3072 (3 gb) is a good one to try
Rishabh
RishabhOPβ€’3mo ago
Hii @Vero πŸ™ @Walshy | Deploying I used 3072 in node options but still get the same error while creating the build. Could you please check it and resolve this issue??
Walshy
Walshyβ€’3mo ago
Again, this is your build taking too much memory. We can offer advise which may help but really the resolution is on you to reduce memory usage
Rishabh
RishabhOPβ€’3mo ago
Yes i understand but can we try to resolve this issue ??
Walshy
Walshyβ€’3mo ago
What would you like us to do to resolve it?
Rishabh
RishabhOPβ€’3mo ago
can you increase the memory limit for the above account??
Walshy
Walshyβ€’3mo ago
We already have once and you continued to max it We cannot just keep increasing forever until you maybe stop using it all I can ping the PM again but realistically, at this point - I think you need to just work on reducing memory
Rishabh
RishabhOPβ€’3mo ago
for the above account i don't thinl memory is increased
Walshy
Walshyβ€’3mo ago
it did. I have verified it
Rishabh
RishabhOPβ€’3mo ago
You increased for the another account Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev
Walshy
Walshyβ€’3mo ago
We increased for all accounts
Rishabh
RishabhOPβ€’3mo ago
ohh okay Yeah It would be great if you can increase it. Also i am checking at my end if i am able to reduce the memory
aniniflare
aniniflareβ€’3mo ago
Hi Rishabh, I'm the PM on builds. What framework are you using? I know some frameworks like Hugo will just gobble up as much memory as you give it. Please try reducing memory and let us know how it goes.
Rishabh
RishabhOPβ€’3mo ago
Hii @aniniflare , I am using Next.js framework I tried all of these 1. Reduce concurrency settings in my build (if applicable.) Eg. next.js defaults to 7 threads that can be overridden by specifying experimental.cpus: 4. 2. Reduce Node memory by specifying an environment variable: NODE_OPTIONS=--max-old-space-size=3072 These configs i have tried but still i am not able to create builds in cloudflare Error occurs: "Build Failed: build exceeded memory limit and was terminated" Account Id: 4560521b37ec36cdd602aa2527f0dfea Zone : 22q.pages.dev Deployment Id: 358a69b2-1b09-468f-af53-d7905daa747b @aniniflare Did you get a chance to look into it??
aniniflare
aniniflareβ€’3mo ago
Hi Rishabh, after looking into it, unfortunately, I don't believe we'll be able to increase the memory limit for you again. We are limited as to how much we can provide per user. We do want to support you as best we can. Please feel free to use us as a resource or crowdsource the community for ways to reduce memory consumption in your project. 🧑
Want results from more Discord servers?
Add your server