FATAL ERROR. Reached Heap Limit Nuxt 3

Currently having issues with a branch deploy on site id: bb865037-1d58-4682-af9f-bc81ea95977d

Framework I am using is Nuxt 3.

2:38:46 PM: Functions bundling                                            
2:38:46 PM: ────────────────────────────────────────────────────────────────
2:38:46 PM: ​
2:38:46 PM: Packaging Functions from .netlify/functions-internal directory:
2:38:46 PM:  - server/server.mjs
2:38:46 PM: ​
2:38:52 PM: <--- Last few GCs --->
2:38:52 PM: [3879:0x60ac940]    30642 ms: Scavenge 2023.6 (2081.2) -> 2023.2 (2082.2) MB, 4.1 / 0.0 ms  (average mu = 0.524, current mu = 0.373) allocation failure;
2:38:52 PM: [3879:0x60ac940]    30649 ms: Scavenge 2025.3 (2082.9) -> 2024.8 (2087.7) MB, 3.9 / 0.0 ms  (average mu = 0.524, current mu = 0.373) allocation failure;
2:38:52 PM: [3879:0x60ac940]    30781 ms: Mark-sweep 2030.7 (2090.4) -> 2029.1 (2092.9) MB, 125.2 / 0.0 ms  (average mu = 0.422, current mu = 0.212) allocation failure; scavenge might not succeed
2:38:52 PM: <--- JS stacktrace --->
2:38:52 PM: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
2:38:52 PM:  1: 0xb83f50 node::Abort() [/opt/buildhome/node-deps/node]
2:38:52 PM:  2: 0xa94834  [/opt/buildhome/node-deps/node]
2:38:52 PM:  3: 0xd647c0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/node-deps/node]
2:38:52 PM:  4: 0xd64b67 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/buildhome/node-deps/node]
2:38:52 PM:  5: 0xf42265  [/opt/buildhome/node-deps/node]
2:38:52 PM:  6: 0xf5474d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/buildhome/node-deps/node]
2:38:52 PM:  7: 0xf2ee4e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/buildhome/node-deps/node]
2:38:52 PM:  8: 0xf30217 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/buildhome/node-deps/node]
2:38:52 PM:  9: 0xf1102b v8::internal::Factory::New(v8::internal::Handle<v8::internal::Map>, v8::internal::AllocationType) [/opt/buildhome/node-deps/node]
2:38:52 PM: 10: 0xf13f8c v8::internal::Factory::NewProperSubString(v8::internal::Handle<v8::internal::String>, int, int) [/opt/buildhome/node-deps/node]
2:38:52 PM: 11: 0x12ee237 v8::internal::Runtime_StringSplit(int, unsigned long*, v8::internal::Isolate*) [/opt/buildhome/node-deps/node]
2:38:52 PM: 12: 0x17035b9  [/opt/buildhome/node-deps/node]
2:38:53 PM: /opt/build-bin/build: line 130:  3879 Aborted                 (core dumped) FORCE_COLOR=1 $netlify_build_node_bin $netlify_build_bin --cwd=$repository_root --repositoryRoot=$repository_root --packagePath=$package_path --config=$configuration_file_path --branch=$branch --siteId=$site_id --defaultConfig=$default_config --baseRelDir=$base_rel_dir --context=$context --node-path=$user_node_path --cachedConfigPath=$cached_netlify_build_config_file --api-host=$netlify_endpoint --token=$netlify_token --build-id=$BUILD_ID --deploy-id=$DEPLOY_ID --mode=buildbot --telemetry=$build_telemetry --send-status --save-config --statsd.host=$HOST_NODE_IP --statsd.port=$STATSD_PORT --tracing.enabled=$tracing_enabled --tracing.sampleRate=$tracing_sample_rate --tracing.host=$HOST_NODE_IP --tracing.traceId=$trace_id --tracing.parentSpanId=$parent_span_id --tracing.traceFlags=$trace_flags --functions-dist-dir=$functions_dist_dir --edge-functions-dist-dir=$edge_functions_dist_dir --cache-dir=$cache_dir --buildbot-server-socket=$buildbot_server_socket --framework=$framework --feature-flags=$feature_flags --testOpts.silentLingeringProcesses=$SILENT_LINGERING_PROCESSES --system-log-file=$system_log_file --explicit-secret-keys=$explicit_secret_keys
2:38:59 PM: Error running command: Build script returned non-zero exit code: 134
2:38:59 PM: Failing build: Failed to build site
2:38:59 PM: Finished processing build request in 1m39.421s

Worked like a charm. Thanks a lot :wink:

glad to hear it! thanks for writing back in.

Hey @hrishikesh

I’m getting the same issue with the lastest nuxt version and adding those lines to nuxt.config didn’t help.
Any ideas that could help us?

@andrevf When you say “the same issue” do you mean exactly the same issue with the assumed same root cause, or just a “running out of memory” error like:

2:38:52 PM: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

If you think it’s potentially different, you may want to create your own thread and supply your build log.

@andrevf, you might want to check out this one: Build error, nuxt3 on netlify edge - #3 by SveinnB, where it was an error with one of the dependencies. As mentioned there, if whatever has been suggested so far doesn’t help, it’s unlikely we could be able to do much here.