From fbda1e34017ea9662afc26b9478fb9fb80b37f7b Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Tue, 3 Nov 2026 15:40:09 +0100 Subject: [PATCH] fix: keep the Docker build within Node's default heap #1510 --- lib/__tests__/next-config-build-worker.test.ts | 11 +++++++++++ next.config.ts | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 lib/__tests__/next-config-build-worker.test.ts diff --git a/lib/__tests__/next-config-build-worker.test.ts b/lib/__tests__/next-config-build-worker.test.ts new file mode 100644 index 000000000..286e0634f --- /dev/null +++ b/lib/__tests__/next-config-build-worker.test.ts @@ -0,0 +1,11 @@ +import { describe, expect, it } from 'vitest'; +import config from '../../next.config'; + +describe('webpack build worker', () => { + // Next turns the workers off for a config with a webpack hook unless the + // option is set, and the Docker build then runs out of heap (#1510). + it('stays on although next-intl adds a webpack hook', () => { + expect(config.webpack).toBeTypeOf('function'); + expect(config.experimental?.webpackBuildWorker).toBe(true); + }); +}); diff --git a/next.config.ts b/next.config.ts index ba49d2cc2..eaea73d23 100644 --- a/next.config.ts +++ b/next.config.ts @@ -102,6 +102,13 @@ const nextConfig: NextConfig = { typescript: { tsconfigPath: "tsconfig.build.json", }, + // next-intl's plugin adds a webpack hook, and with one Next runs the client, + // server and edge compilers in its main process on one heap, which outgrew + // Node's default limit of about 2.2 GB (#1510). In workers each compiler has + // its own heap, freed when it finishes. Turbopack builds don't read this. + experimental: { + webpackBuildWorker: true, + }, // No proxyClientMaxBodySize: Next copies every body proxy.ts runs for up to // that size before routing, so it stays at the 10 MB default. The routes // that take bigger uploads (WOPI saves, WebDAV, /api/plugin-proxy) are left