AstroJS builds fail with 137 on the image processing stage

Hey folks, I cannot build my AstroJS-based blog because of OOM error on the image processing stage:

7:32:06 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
7:28:32 PM: Netlify Build                                                 
7:28:32 PM: ────────────────────────────────────────────────────────────────
7:28:32 PM: ​
7:28:32 PM: ❯ Version
7:28:32 PM:   @netlify/build 29.20.6
7:28:32 PM: ​
7:28:32 PM: ❯ Flags
7:28:32 PM:   baseRelDir: true
7:28:32 PM:   buildId: 64e23f07c07fa07c460ce588
7:28:32 PM:   deployId: 64e23f07c07fa07c460ce58a
7:28:32 PM: ​
7:28:32 PM: ❯ Current directory
7:28:32 PM:   /opt/build/repo/astro
7:28:32 PM: ​
7:28:32 PM: ❯ Config file
7:28:32 PM:   No config file was defined: using default values.
7:28:32 PM: ​
7:28:32 PM: ❯ Context
7:28:32 PM:   production
7:28:32 PM: ​
7:28:32 PM: Build command from Netlify app                                
7:28:32 PM: ────────────────────────────────────────────────────────────────
7:28:32 PM: ​
7:28:32 PM: $ yarn build
7:28:32 PM: yarn run v1.17.0
7:28:32 PM: warning package.json: No license field
7:28:32 PM: $ astro build
7:28:33 PM: (node:5886) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.
7:28:33 PM: (Use `node --trace-warnings ...` to show where the warning was created)
7:28:33 PM: (node:5886) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
7:28:33 PM: 04:28:33 PM [content] Unsupported file types found. Prefix with an underscore (`_`) to ignore:
7:28:33 PM: - collections.ts
7:28:33 PM: routing.tsx
7:28:33 PM: 04:28:33 PM [content] Types generated 301ms
7:28:33 PM: 04:28:33 PM [build] output target: static
7:28:33 PM: 04:28:33 PM [build] Collecting build info...
7:28:33 PM: 04:28:33 PM [build] Completed in 413ms.
7:28:33 PM: 04:28:33 PM [build] Building static entrypoints...
7:28:42 PM: 04:28:42 PM [build] Completed in 9.19s.
7:28:42 PM: 
7:28:42 PM:  building client 
7:28:49 PM: Generated an empty chunk: hoisted.
7:28:49 PM: 
7:28:49 PM: (!) Some chunks are larger than 500 kBs after minification. Consider:
7:28:49 PM: - Using dynamic import() to code-split the application
7:28:49 PM: - Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
7:28:49 PM: - Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
7:28:49 PM: Completed in 6.99s.
7:28:49 PM: 
7:28:49 PM: 
7:28:49 PM:  generating static routes 
7:28:50 PM: ▶ src/pages/index.astro
7:28:50 PM:   └─ /index.html (+178ms)
7:28:50 PM: ▶ src/pages/thoughts/index.astro
7:28:50 PM:   └─ /thoughts/index.html (+40ms)
7:28:50 PM: ▶ src/pages/thoughts/[...slug].astro
7:28:50 PM:   ├─ /thoughts/buy-opensource-build/index.html (+39ms)
7:28:50 PM:   ├─ /thoughts/promotion-paradoxes/index.html (+75ms)
7:28:50 PM:   ├─ /thoughts/sunday-morning-problem/index.html (+112ms)
7:28:50 PM:   ├─ /thoughts/360-review-is-dead/index.html (+150ms)
7:28:50 PM:   ├─ /thoughts/power-of-no-action/index.html (+198ms)
7:28:50 PM:   ├─ /thoughts/factors-affecting-decision-making/index.html (+286ms)
7:28:50 PM:   ├─ /thoughts/disadvantages-are-everywhere/index.html (+324ms)
7:28:50 PM:   ├─ /thoughts/measure-and-improve/index.html (+360ms)
7:28:50 PM:   ├─ /thoughts/just-ask/index.html (+396ms)
7:28:50 PM:   ├─ /thoughts/normal-life/index.html (+434ms)
7:28:50 PM:   └─ /thoughts/focus-on-solutions-not-on-problems/index.html (+469ms)
7:28:50 PM: λ src/pages/rss.xml.js
7:28:50 PM:   └─ /rss.xml (+17ms)
7:28:50 PM: ▶ src/pages/blog/index.astro
7:28:50 PM:   └─ /blog/index.html (+163ms)
7:28:50 PM: ▶ src/pages/blog/[...slug].astro
7:28:50 PM:   ├─ /blog/react-hooks/index.html (+47ms)
7:28:50 PM:   ├─ /blog/communicate-through-code/index.html (+101ms)
7:28:51 PM:   ├─ /blog/nature-of-distributed-systems/index.html (+135ms)
7:28:51 PM:   ├─ /blog/design-lru-cache/index.html (+172ms)
7:28:51 PM:   ├─ /blog/heapify/index.html (+209ms)
7:28:51 PM:   ├─ /blog/how-i-built-my-ml-workstation/index.html (+253ms)
7:28:51 PM:   ├─ /blog/k-nearest-neighbors/index.html (+292ms)
7:28:51 PM:   └─ /blog/rock-paper-scissors/index.html (+330ms)
7:28:51 PM: ▶ src/pages/404.astro
7:28:51 PM:   └─ /404.html (+53ms)
7:28:51 PM: ▶ src/pages/cv/index.astro
7:28:51 PM:   └─ /cv/index.html (+37ms)
7:28:51 PM: ▶ src/pages/cv/[...slug].astro
7:28:51 PM:   ├─ /cv/ecommerce-developer/index.html (+39ms)
7:28:51 PM:   ├─ /cv/machine-learning-engineer/index.html (+75ms)
7:28:51 PM:   └─ /cv/software-engineer/index.html (+112ms)
7:28:51 PM:  optimizing 20 images in batches of 32 
7:28:54 PM: 04:28:54 PM [build] Waiting for the @astrojs/image integration...
7:31:40 PM: Killed
7:31:40 PM: error Command failed with exit code 137. (https://ntl.fyi/exit-code-137)
7:31:40 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7:31:40 PM: ​
7:31:40 PM: build.command failed                                        
7:31:40 PM: ────────────────────────────────────────────────────────────────
7:31:40 PM: ​
7:31:40 PM:   Error message
7:31:40 PM:   Command failed with exit code 137: yarn build (https://ntl.fyi/exit-code-137)
7:31:40 PM: ​
7:31:40 PM:   Error location
7:31:40 PM:   In Build command from Netlify app:
7:31:40 PM:   yarn build
7:31:40 PM: ​
7:31:40 PM:   Resolved config
7:31:40 PM:   build:
7:31:40 PM:     base: /opt/build/repo/astro
7:31:40 PM:     command: yarn build
7:31:40 PM:     commandOrigin: ui
7:31:40 PM:     publish: /opt/build/repo/astro/dist
7:31:40 PM:     publishOrigin: ui
7:32:06 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:32:06 PM: Failing build: Failed to build site
7:32:06 PM: Finished processing build request in 4m12.805s

I have no issue buliding that revision locally or on Vercel. Is there something we can do with this?

The build is getting killed. As you have understood, it’s running out of memory. If your build can’t complete within 8 GB on the Starter tier or 11 GB on the Pro tier, unfortunately it won’t work on Netlify.