next-on-pages: [π Bug]: Failed: build exceeded memory limit and was terminated
next-on-pages environment related information
node v: v18.16.0
Description
I have a large project and migrating Cloudflare, Trying to deploy to Cloudflare pages but while building the application I get this error.
Failed: build exceeded memory limit and was terminated
Also I get this message when I build the application locally with npx @cloudflare/next-on-pages@latest.
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
Full Log:
β² β (Streaming) server-side renders with streaming (uses React 18 SSR streaming or Server Components)
β² β (Static) automatically rendered as static HTML (uses no initial props)
β² Traced Next.js server files in: 27.112ms
β² Created all serverless functions in: 1:02.051 (m:ss.mmm)
β² Collected static files (public/, static/, .next/static): 37.616ms
β² Warning: Node.js functions are compiled from ESM to CommonJS. If this is not intended, add "type": "module" to your package.json file.
β² Compiling "middleware.js" from ESM to CommonJS...
β² Build Completed in .vercel/output [4m]
β‘οΈ Completed `yarn vercel build`.
<--- Last few GCs --->
[22466:0x7fd95284d000] 267301 ms: Mark-sweep (reduce) 4073.1 (4143.3) -> 4072.7 (4143.6) MB, 2833.6 / 0.0 ms (average mu = 0.107, current mu = 0.002) allocation failure; scavenge might not succeed
[22466:0x7fd95284d000] 270200 ms: Mark-sweep (reduce) 4073.9 (4143.6) -> 4073.4 (4144.3) MB, 2893.0 / 0.0 ms (average mu = 0.056, current mu = 0.002) allocation failure; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 0x101b8ceb5 node::Abort() (.cold.1) [/usr/local/bin/node]
2: 0x100602a69 node::Abort() [/usr/local/bin/node]
3: 0x100602c4e node::OOMErrorHandler(char const*, bool) [/usr/local/bin/node]
4: 0x10078e653 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
5: 0x100957305 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
6: 0x100955ce2 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
7: 0x10094801a v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
8: 0x100948995 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
9: 0x10092ae0e v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
10: 0x100d60c6c v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
11: 0x1011567f9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node]
12: 0x10619d871
Done in 275.52s.
is there any way that I can increase the memory in while building in pages? or any other suggestions?
Reproduction
No response
Pages Deployment Method
None
Pages Deployment ID
No response
Additional Information
Would you like to help?
- Would you like to help fixing this bug?
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 3
- Comments: 16 (8 by maintainers)
Iβm closing this issue as I believe that the problems mentioned here have been solved (we no longer produce huge build outputs)
There is still the issue with large applications potentially hitting the message too large error, but thatβs already recorded in https://github.com/cloudflare/workers-sdk/issues/3391 (and Iβm looking into it and trying to find a solution)
I hope you donβt mind @anonymouscatcher