FATAL ERROR: Ineffective mark-compacts near heap limit (Nuxt)

Hello!

I’ve had a baffling drop in performance on my application, Netlify build times have tripled and frequently fail altogether (5 – 8 minutes !!)

There’s nothing wholly unusual about the site, in that I’ve built 15+ sites with Netlify and Nuxt now, using the same boilerplate with no ill-effects elsewhere.

Any help much appreciated! Error below…

climaxlooks.netlify.app

12:15:35 AM: Build ready to start
12:15:37 AM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
12:15:37 AM: build-image tag: v3.4.1
12:15:37 AM: buildbot version: fcbc7a79f7372e5995cf02954ef19fc48d20c871
12:15:37 AM: Building without cache
12:15:37 AM: Starting to prepare the repo for build
12:15:38 AM: No cached dependencies found. Cloning fresh repo
12:15:38 AM: git clone https://github.com/simonhrogers/Climax-Books_Snipcart
12:15:39 AM: Preparing Git Reference refs/heads/shop
12:15:40 AM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'functions' versus '' in the Netlify UI
12:15:40 AM: Starting build script
12:15:40 AM: Installing dependencies
12:15:40 AM: Python version set to 2.7
12:15:41 AM: v12.18.0 is already installed.
12:15:42 AM: Now using node v12.18.0 (npm v6.14.4)
12:15:42 AM: Started restoring cached build plugins
12:15:42 AM: Finished restoring cached build plugins
12:15:42 AM: Attempting ruby version 2.7.1, read from environment
12:15:43 AM: Using ruby version 2.7.1
12:15:44 AM: Using PHP version 5.6
12:15:44 AM: 5.2 is already installed.
12:15:44 AM: Using Swift version 5.2
12:15:44 AM: Started restoring cached node modules
12:15:44 AM: Finished restoring cached node modules
12:15:44 AM: Installing NPM modules using NPM version 6.14.4
12:16:09 AM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
12:16:09 AM: > node scripts/install.js
12:16:10 AM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
12:16:10 AM: Download complete
12:16:10 AM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
12:16:11 AM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-72_binding.node
12:16:11 AM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/core-js
12:16:11 AM: > node -e "try{require('./postinstall')}catch(e){}"
12:16:11 AM: > ejs@2.7.4 postinstall /opt/build/repo/node_modules/ejs
12:16:11 AM: > node ./postinstall.js
12:16:11 AM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
12:16:11 AM: > node scripts/build.js
12:16:12 AM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
12:16:12 AM: Testing binary
12:16:12 AM: Binary is fine
12:16:12 AM: > nuxt@2.14.4 postinstall /opt/build/repo/node_modules/nuxt
12:16:12 AM: > opencollective || exit 0
12:16:13 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
12:16:13 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:16:13 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/@babel/cli/node_modules/fsevents):
12:16:13 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:16:13 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
12:16:13 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:16:13 AM: added 1541 packages from 732 contributors and audited 1548 packages in 28.425s
12:16:14 AM: 59 packages are looking for funding
12:16:14 AM:   run `npm fund` for details
12:16:14 AM: found 0 vulnerabilities
12:16:14 AM: NPM modules installed
12:16:15 AM: Started restoring cached go cache
12:16:15 AM: Finished restoring cached go cache
12:16:15 AM: go version go1.14.4 linux/amd64
12:16:15 AM: go version go1.14.4 linux/amd64
12:16:15 AM: Installing missing commands
12:16:15 AM: Verify run directory
12:16:16 AM: ​
12:16:16 AM: ┌─────────────────────────────┐
12:16:16 AM: │        Netlify Build        │
12:16:16 AM: └─────────────────────────────┘
12:16:16 AM: ​
12:16:16 AM: ❯ Version
12:16:16 AM:   @netlify/build 3.3.0
12:16:16 AM: ​
12:16:16 AM: ❯ Flags
12:16:16 AM:   deployId: 5f4d84977cc5340df37535fc
12:16:16 AM:   mode: buildbot
12:16:16 AM: ​
12:16:16 AM: ❯ Current directory
12:16:16 AM:   /opt/build/repo
12:16:16 AM: ​
12:16:16 AM: ❯ Config file
12:16:16 AM:   /opt/build/repo/netlify.toml
12:16:16 AM: ​
12:16:16 AM: ❯ Context
12:16:16 AM:   production
12:16:17 AM: ​
12:16:17 AM: ┌────────────────────────────────────┐
12:16:17 AM: │ 1. build.command from netlify.toml │
12:16:17 AM: └────────────────────────────────────┘
12:16:17 AM: ​
12:16:17 AM: $ npm run generate
12:16:17 AM: > climax@1.0.1 generate /opt/build/repo
12:16:17 AM: > nuxt generate --quiet
12:19:35 AM: <--- Last few GCs --->
12:19:35 AM: [1425:0x3d7d300]   196309 ms: Scavenge 2033.5 (2049.7) -> 2032.5 (2049.7) MB, 4.1 / 0.0 ms  (average mu = 0.183, current mu = 0.000) allocation failure
12:19:35 AM: [1425:0x3d7d300]   196318 ms: Scavenge 2033.5 (2049.7) -> 2032.6 (2049.7) MB, 4.3 / 0.0 ms  (average mu = 0.183, current mu = 0.000) allocation failure
12:19:35 AM: [1425:0x3d7d300]   196327 ms: Scavenge 2033.5 (2049.7) -> 2032.6 (2049.7) MB, 3.7 / 0.0 ms  (average mu = 0.183, current mu = 0.000) allocation failure
12:19:35 AM: <--- JS stacktrace --->
12:19:35 AM: ==== JS stack trace =========================================
12:19:35 AM:     0: ExitFrame [pc: 0x13cb519]
12:19:35 AM: Security context: 0x17a5256408d1 <JSObject>
12:19:35 AM:     1: set [0x17a52564a791](this=0x33670cc2d4a9 <Map map = 0x7c215500899>,0x0efdecd04e69 <JSArray[0]>,1)
12:19:35 AM:     2: walk(aka walk) [0x3c348ffa0f61] [/opt/build/repo/node_modules/@nuxt/devalue/dist/devalue.cjs.js:~35] [pc=0x3a8cbb109d5f](this=0x180fdd8804b1 <undefined>,0x0efdecd04e69 <JSArray[0]>)
12:19:35 AM:     3: walk(aka walk) [0x3c348ffa0f61] [/opt/build/repo/node_modules/@n...
12:19:35 AM: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
12:19:35 AM:  1: 0xa07f90 node::Abort() [node]
12:19:35 AM:  2: 0xa0839c node::OnFatalError(char const*, char const*) [node]
12:19:35 AM:  3: 0xb80d9e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
12:19:35 AM:  4: 0xb81119 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
12:19:35 AM:  5: 0xd2d875  [node]
12:19:35 AM:  6: 0xd2df06 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
12:19:35 AM:  7: 0xd3a785 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
12:19:35 AM:  8: 0xd3b635 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
12:19:35 AM:  9: 0xd3e0ec v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
12:19:35 AM: 10: 0xd0502d v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::RootIndex, int, v8::internal::Object, v8::internal::AllocationType) [node]
12:19:35 AM: 11: 0xd05120 v8::internal::Handle<v8::internal::FixedArray> v8::internal::Factory::NewFixedArrayWithMap<v8::internal::FixedArray>(v8::internal::RootIndex, int, v8::internal::AllocationType) [node]
12:19:35 AM: 12: 0xf33170 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Allocate(v8::internal::Isolate*, int, v8::internal::AllocationType) [node]
12:19:35 AM: 13: 0xf33221 v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Rehash(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashMap>, int) [node]
12:19:35 AM: 14: 0xf3386b v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::EnsureGrowable(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashMap>) [node]
12:19:35 AM: 15: 0x1029ff8 v8::internal::Runtime_MapGrow(int, unsigned long*, v8::internal::Isolate*) [node]
12:19:35 AM: 16: 0x13cb519  [node]
12:19:45 AM: Aborted (core dumped)
12:19:45 AM: npm ERR! code ELIFECYCLE
12:19:45 AM: npm ERR! errno 134
12:19:45 AM: npm ERR! climax@1.0.1 generate: `nuxt generate --quiet`
12:19:45 AM: npm ERR! Exit status 134
12:19:45 AM: npm ERR!
12:19:45 AM: npm ERR! Failed at the climax@1.0.1 generate script.
12:19:45 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:19:45 AM: npm ERR! A complete log of this run can be found in:
12:19:45 AM: npm ERR!     /opt/buildhome/.npm/_logs/2020-08-31T23_19_45_884Z-debug.log
12:19:45 AM: ​
12:19:45 AM: ┌─────────────────────────────┐
12:19:45 AM: │   "build.command" failed    │
12:19:45 AM: └─────────────────────────────┘
12:19:45 AM: ​
12:19:45 AM:   Error message
12:19:45 AM:   Command failed with exit code 134: npm run generate
12:19:45 AM: ​
12:19:45 AM:   Error location
12:19:45 AM:   In build.command from netlify.toml:
12:19:45 AM:   npm run generate
12:19:45 AM: ​
12:19:45 AM:   Resolved config
12:19:45 AM:   build:
12:19:45 AM:     command: npm run generate
12:19:45 AM:     commandOrigin: config
12:19:45 AM:     environment:
12:19:45 AM:       - SENDGRID_API_KEY
12:19:45 AM:       - SENDGRID_SENDER_EMAIL
12:19:45 AM:       - SENDGRID_SENDER_NAME
12:19:45 AM:       - CI
12:19:45 AM:     functions: /opt/build/repo/functions
12:19:45 AM:     publish: /opt/build/repo/dist
12:19:46 AM: Caching artifacts
12:19:46 AM: Started saving node modules
12:19:46 AM: Finished saving node modules
12:19:46 AM: Started saving build plugins
12:19:46 AM: Finished saving build plugins
12:19:46 AM: Started saving pip cache
12:19:46 AM: Finished saving pip cache
12:19:46 AM: Started saving emacs cask dependencies
12:19:46 AM: Finished saving emacs cask dependencies
12:19:46 AM: Started saving maven dependencies
12:19:46 AM: Finished saving maven dependencies
12:19:46 AM: Started saving boot dependencies
12:19:46 AM: Finished saving boot dependencies
12:19:46 AM: Started saving go dependencies
12:19:46 AM: Finished saving go dependencies
12:19:48 AM: Error running command: Build script returned non-zero exit code: 1
12:19:48 AM: Failing build: Failed to build site
12:19:48 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
12:19:49 AM: Finished processing build request in 4m11.381080124s

Hi, @simonhrogers. That out of memory (OOM) error above can often be resolved with the following environment variable:

NODE_OPTIONS="--max-old-space-size=4096"

You can add that in netlify.toml on in the web UI for the site (under Site Name > Settings > Build & deploy > Environment).

Also, something is changing about that site’s build. For the longest deploy I can find there are 367 files in the deploy and 563 seconds were spent building:

For a more recent deploy there were only 218 files created and the time to build was 316 seconds:

To summarize, the longer build times do appear to be correlated with more files than the shorter deploys. Something is changing about this site build and more files generated means a longer build.

If there are other questions about this, please let us know.