From 3d828a61ab751cf3aa55fb86c1e51c93e16b6a9b Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 4 Oct 2026 18:50:11 +0200 Subject: [PATCH] fix(build): build with webpack because the Turbopack build is OOM-killed `next build` on Turbopack never completes on this app. The compiler is a single native process whose RSS grows monotonically with no plateau: 0.9G -> 1.6G -> 2.8G -> 5.0G -> 5.5G -> 6.2G -> killed It still dies with 4GB of swap attached, at 12GB RSS. The build workers are only 0.17GB each, so `experimental.cpus` is not the lever either. A `--max-old-space-size` cap cannot help: measured with a 2GB cap, RSS still reached 8GB, because the memory is native Turbopack (Rust) memory rather than the V8 heap. The cap added in 1c9ddcd4 was therefore inert and only created false confidence, so it is dropped from the build script. Webpack builds the same 329 routes in ~95s with a ~6GB peak. Ruled out by measurement: the 25 bundled locale files (stubbing 24 of them from 7.1MB down to 276KB still peaked at 11GB), worker count, and the flatten/unflatten message pipeline (600 iterations cost 6.4s and settle at 39MB of heap). Verified: `pnpm run build` exits 0, TypeScript passes, 279/279 static pages are generated, and the standalone output boots and serves /, /login and /register. --- Dockerfile | 6 +++++- package.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9f77a338..805d28b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,11 @@ FROM migrations AS builder ARG NEXT_DEPLOYMENT_ID="unknown" ENV NEXT_DEPLOYMENT_ID="$NEXT_DEPLOYMENT_ID" -# Fix voor OOM Killer: dwing de Node-compiler om agressief op te ruimen bij 4GB RAM +# The build runs the webpack builder (see the `build` script in package.json). +# Turbopack's compiler is a single native process that grows past 12GB RSS on +# this 329-route app and gets OOM-killed; webpack peaks around 5GB. A +# --max-old-space-size cap does NOT help, because that memory is native +# Turbopack memory rather than the V8 heap. ENV NODE_OPTIONS="--max-old-space-size=4096" # Bouw de Next.js applicatie met caching diff --git a/package.json b/package.json index f1ecd9bb..af74c1f3 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "packageManager": "pnpm@12.8.1", "scripts": { "dev": "pnpm assets:editor && next dev", - "build": "pnpm assets:editor && NODE_OPTIONS='--max-old-space-size=4096' next build", + "build": "pnpm assets:editor && next build --webpack", "start": "next start", "toolchain:check": "node scripts/check-node-toolchain.mjs", "lint": "biome check . || true",