Running out of memory in build step of SvelteKit App (Workers)

We're trying to build our SvelteKit-based app from our Monorepo (Turborepo) with Workers Builds, but are facing the typical Node OOM errors as we're seemingly hitting the 8GB limit inside the build step. Running the same process with busted caches, mirrored commands and everything leads to ~4GB of used memory at the end of bundling the whole application on my local machine (Macbook Pro M1). We haven't had this issue with our old builds with Pages, but wanted to move to the new builds and Workers runtime as it provides better logging out of the box and is now recommended on the CF dashboard. Is there something that eats the other half that can't be removed, or are there some gotchas to be aware of when it comes to Workers Builds at this stage? Below are the errors from the Node GC (fails towards the end of the Rollup process):
02:21:40.815 @mure/app:build: ----- Native stack trace -----
02:21:40.815 @mure/app:build:
02:21:40.815 @mure/app:build: 1: 0xf1f241 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
02:21:40.815 @mure/app:build: 2: 0x13563a0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
02:21:40.815 @mure/app:build: 3: 0x135648f v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
02:21:40.816 @mure/app:build: 4: 0x15ecad5 [node]
02:21:40.816 @mure/app:build: 5: 0x15ecb02 [node]
02:21:40.816 @mure/app:build: 6: 0x15ecdfa v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector, v8::base::TimeTicks) [node]
02:21:40.816 @mure/app:build: 7: 0x15fd31a [node]
02:21:40.815 @mure/app:build: ----- Native stack trace -----
02:21:40.815 @mure/app:build:
02:21:40.815 @mure/app:build: 1: 0xf1f241 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
02:21:40.815 @mure/app:build: 2: 0x13563a0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
02:21:40.815 @mure/app:build: 3: 0x135648f v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
02:21:40.816 @mure/app:build: 4: 0x15ecad5 [node]
02:21:40.816 @mure/app:build: 5: 0x15ecb02 [node]
02:21:40.816 @mure/app:build: 6: 0x15ecdfa v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector, v8::base::TimeTicks) [node]
02:21:40.816 @mure/app:build: 7: 0x15fd31a [node]
2 Replies
Rhaegal
Rhaegal5mo ago
You can set a build variable NODE_OPTIONS with the content --max-old-space-size=6144. This resolved the issues for me.
felixnorden
felixnordenOP5mo ago
Ty that solved it @Rhaegal , I thought it was set to 8GB out of the box, for some reason when reading the forums

Did you find this page helpful?