RangeError: Invalid array length
Unanswered
Jersey Wooly posted this in #help-forum
Jersey WoolyOP
Title: next build fails with "JavaScript heap out of memory" and later "RangeError: Invalid array length"
Environment:
Node.js version: 22.17.1 or 20+
Next.js version: 15.4.4
pnpm version: 11.5.1 or 10.9.2
During docker compose up, the process crashes with the following fatal error: The following error only occurs with Docker.
RangeError: Invalid array length
at Array.push (<anonymous>)
Steps to Reproduce:
Expected Behavior:
Build should complete successfully without exhausting memory or crashing.
Dockerfile:
Environment:
Node.js version: 22.17.1 or 20+
Next.js version: 15.4.4
pnpm version: 11.5.1 or 10.9.2
During docker compose up, the process crashes with the following fatal error: The following error only occurs with Docker.
RangeError: Invalid array length
at Array.push (<anonymous>)
Steps to Reproduce:
Expected Behavior:
Build should complete successfully without exhausting memory or crashing.
Dockerfile:
ARG NODE_VERSION=22.17.1
FROM node:${NODE_VERSION}-slim AS base
ENV PORT=3000
ENV NEXT_TELEMETRY_DISABLED=1
WORKDIR /app
COPY /apps/dashboard/package.json /apps/dashboard/package-lock.json ./
RUN npm ci
RUN npm run build
FROM base AS run
ENV NODE_ENV=production
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]