Killed error without description

Our upbeat-shaw-75fa27 are having multiple “Killed” error in sequence without any description or reason. We increased the --max_old_space_size to 8192, and keep receiving this kind of errors sometimes.

netlify.toml

[build.environment]
  NODE_OPTIONS = "--max_old_space_size=8192"

[build]
  command = "yarn build"

DEPLOY LOG

10:55:16 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:53:49 AM: Netlify Build                                                 
10:53:49 AM: ────────────────────────────────────────────────────────────────
10:53:49 AM: ​
10:53:49 AM: ❯ Version
10:53:49 AM:   @netlify/build 29.16.4
10:53:49 AM: ​
10:53:49 AM: ❯ Flags
10:53:49 AM:   baseRelDir: true
10:53:49 AM:   buildId: 64b7ea9e0d49b313342cc161
10:53:49 AM:   deployId: 64b7ea9e0d49b313342cc163
10:53:49 AM: ​
10:53:49 AM: ❯ Current directory
10:53:49 AM:   /opt/build/repo
10:53:49 AM: ​
10:53:49 AM: ❯ Config file
10:53:49 AM:   /opt/build/repo/netlify.toml
10:53:49 AM: ​
10:53:49 AM: ❯ Context
10:53:49 AM:   deploy-preview
10:53:49 AM: ​
10:53:49 AM: build.command from netlify.toml                               
10:53:49 AM: ────────────────────────────────────────────────────────────────
10:53:49 AM: ​
10:53:49 AM: $ yarn build
10:53:49 AM: yarn run v1.22.19
10:53:49 AM: $ gatsby build && node ./csp-util.js
10:53:52 AM: success compile gatsby files - 1.046s
10:53:52 AM: success load gatsby config - 0.057s
10:53:52 AM: success load plugins - 0.399s
10:53:52 AM: success onPreInit - 0.000s
10:53:52 AM: success initialize cache - 0.050s
10:53:52 AM: success copy gatsby files - 0.106s
10:53:52 AM: success Compiling Gatsby Functions - 0.148s
10:53:52 AM: success onPreBootstrap - 0.157s
10:53:53 AM: success createSchemaCustomization - 0.000s
10:53:53 AM: success Checking for changed pages - 0.000s
10:53:53 AM: success source and transform nodes - 0.297s
10:53:53 AM: info Writing GraphQL type definitions to /opt/build/repo/.cache/schema.gql
10:53:54 AM: success building schema - 0.787s
10:53:54 AM: success createPages - 0.200s
10:53:57 AM: success createPagesStatefully - 2.806s
10:53:57 AM: info Total nodes: 61, SitePage nodes: 22 (use --verbose for breakdown)
10:53:57 AM: success Checking for changed pages - 0.000s
10:53:57 AM: success onPreExtractQueries - 0.000s
10:54:01 AM: success extract queries from components - 3.802s
10:54:01 AM: success write out redirect data - 0.083s
10:54:01 AM: success onPostBootstrap - 0.000s
10:54:01 AM: info bootstrap finished - 11.805s
10:54:01 AM: success write out requires - 0.006s
10:55:10 AM: Killed
10:55:10 AM: error Command failed with exit code 137. (https://ntl.fyi/exit-code-137)
10:55:10 AM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
10:55:10 AM: ​
10:55:10 AM: build.command failed                                        
10:55:10 AM: ────────────────────────────────────────────────────────────────
10:55:10 AM: ​
10:55:10 AM:   Error message
10:55:10 AM:   Command failed with exit code 137: yarn build (https://ntl.fyi/exit-code-137)
10:55:10 AM: ​
10:55:10 AM:   Error location
10:55:10 AM:   In build.command from netlify.toml:
10:55:10 AM:   yarn build
10:55:16 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:55:16 AM: Failing build: Failed to build site
10:55:17 AM: Finished processing build request in 2m44.679s

Why our builds are being killed? After multiple tries without any changes on the code it sucessfully deploys. But this prevent our CI works without intervention.

Hi, @gengshuo. The clue that points to the root cause is here:

A 137 exit code means that the operating system (Linux) killed the process for exceeding the memory limits of the system. In other words, your build command used more memory than was available and the normal operating system response is to terminate the process when this happens.

The possible solutions for this are:

  • upgrade to an Enterprise plan and add the High-Performance Builds add-on to get more memory for the build at Netlify
  • build locally and deploy to Netlify using the CLI tool to make manual deploys
  • modify the build code to use less memory

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

Apparently nothing works except paying for the Pro tier. It’s ok. But this kind of thing should be explicit. Because the error started to happen when I changed some files, notting added to project itself.