This repository was archived by the owner on Feb 10, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 19
This repository was archived by the owner on Feb 10, 2026. It is now read-only.
Memory leak/excessive memory usage during Next.js build in v3.2.1 #610
Copy link
Copy link
Closed
Description
Upgrading @zenstackhq packages from v3.1.1 to v3.2.1 causes a JavaScript heap out of memory error during Next.js production builds. The build process crashes during the optimization phase with FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory.
Environment
- Node.js version: v24.4.0
- Next.js version: 15.5.9
- pnpm version: 10.27.0
- OS: macOS (darwin 25.2.0)
- ZenStack packages affected:
@zenstackhq/orm: 3.1.1 → 3.2.1@zenstackhq/plugin-policy: 3.1.1 → 3.2.1@zenstackhq/server: 3.1.1 → 3.2.1@zenstackhq/tanstack-query: 3.1.1 → 3.2.1@zenstackhq/cli: 3.1.1 → 3.2.1
Steps to Reproduce
- Start with a Next.js 15 project using @zenstackhq packages v3.1.1
- Update all @zenstackhq packages to v3.2.1
- Run production build:
next build - Build crashes during optimization phase with heap out of memory error
Expected Behavior
Build should complete successfully as it does with v3.1.1, using reasonable memory (≤4GB default Node.js heap).
Actual Behavior
Build process crashes after ~2 minutes with:
<--- Last few GCs --->
[39165:0xbee800000] 135344 ms: Mark-Compact 4084.7 (4101.7) -> 4081.0 (4110.0) MB
[39165:0xbee800000] 138846 ms: Mark-Compact (reduce) 4089.1 (4110.0) -> 4083.4 (4097.2) MB
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Next.js build worker exited with code: null and signal: SIGABRT
Testing Details
We performed systematic testing by updating packages individually:
- ✅ All other dependencies (including @tanstack/react-query, ai, react-hook-form, kysely, pg, etc.) updated successfully without issues
- ✅ Build succeeds with v3.1.1
- ❌ Build fails with v3.2.1
- ✅ Downgrading back to v3.1.1 resolves the issue
Project Context
- Large Next.js 15 application with:
- 158 files in
app/directory - 305 files in
components/directory - ZenStack schema generation runs before build
- Uses React 19, TypeScript, and multiple ZenStack plugins
- 158 files in
Workaround
Pin @zenstackhq packages to v3.1.1:
{
"@zenstackhq/orm": "3.1.1",
"@zenstackhq/plugin-policy": "3.1.1",
"@zenstackhq/server": "3.1.1",
"@zenstackhq/tanstack-query": "3.1.1",
"@zenstackhq/cli": "3.1.1"
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels