Unable to build Next.js project after integrating Sentry

My Netlify build has been working flawlessly for months. However, I recently integrated Sentry and ever since the build will fail most of the time. I say most of the time because every once in a while it will work, but most of the time it fails. I’ve checked the logs and even with the Netlify debug environment variable enabled, I can’t track anything down.

Netlify site: north-star-13e184.netlify.app
Build log:

12:54:40 PM: $ next build
12:54:41 PM:   ▲ Next.js 14.2.5
12:54:41 PM:   - Experiments (use with caution):
12:54:41 PM:     · instrumentationHook
12:54:41 PM:    Creating an optimized production build ...
12:57:12 PM:  ✓ Compiled successfully
12:57:12 PM:    Linting and checking validity of types ...
12:57:20 PM:    Collecting page data ...
12:57:26 PM:  ⚠ Using edge runtime on a page currently disables static generation for that page
12:57:32 PM:    Generating static pages (0/50) ...
12:58:08 PM: ​
12:58:08 PM: @netlify/plugin-nextjs (onEnd event)                          
12:58:08 PM: ────────────────────────────────────────────────────────────────
12:58:08 PM: ​
12:58:08 PM: Step starting.
12:58:08 PM: Step started.
12:58:08 PM: Plugin logic started.
12:58:08 PM: Plugin logic ended.
12:58:08 PM: Stop closing.
12:58:08 PM: Step ended.
12:58:08 PM: Step completed.
12:58:08 PM: ​
12:58:08 PM: (@netlify/plugin-nextjs onEnd completed in 21ms)
12:58:08 PM: Build step duration: @netlify/plugin-nextjs onEnd completed in 21ms
12:58:08 PM: Step starting.
12:58:08 PM: Step started.
12:58:08 PM: Step ended.
12:58:08 PM: ​
12:58:08 PM: "build.command" failed                                        
12:58:08 PM: ────────────────────────────────────────────────────────────────
12:58:08 PM: ​
12:58:08 PM:   Error message
12:58:08 PM:   Command was killed with SIGKILL (Forced termination): next build
12:58:08 PM: ​
12:58:08 PM:   Error location
12:58:08 PM:   In Build command from Netlify app:
12:58:08 PM:   next build
12:58:08 PM: ​
12:58:08 PM:   Resolved config
12:58:08 PM:   build:
12:58:08 PM:     command: next build
12:58:08 PM:     commandOrigin: ui
12:58:08 PM:     environment:
12:58:08 PM:       - REDACTED_ALL_OF_THESE
12:58:08 PM:     publish: /opt/build/repo/.next
12:58:08 PM:     publishOrigin: ui
12:58:08 PM:   functions:
12:58:08 PM:     cleanPendingEventBookings:
12:58:08 PM:       schedule: '@hourly'
12:58:08 PM:   functionsDirectory: /opt/build/repo/netlify/functions
12:58:08 PM:   plugins:
12:58:08 PM:     - inputs: {}
12:58:08 PM:       origin: ui
12:58:08 PM:       package: '@netlify/plugin-nextjs'
12:58:09 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:58:09 PM: Failing build: Failed to build site
12:58:10 PM: Finished processing build request in 4m19.111s
12:58:09 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)

If I remove the Sentry configuration the build succeeds.

An example build can be found here…in case a Netlify team member can access it.

I’m scratching my head on this one…can’t figure out what I might be doing wrong.

Your build runs out of memory. You can try setting the cpus experimental config to 1: next.js/packages/next/server/config-shared.ts at f9795fdd2665369b60a153fbb6231f478e4a7d08 · vercel/next.js (github.com)

You just made my day, that definitely did the trick. Thank you!