Skip to content

fix: give the renderer Vite build a 4 GiB heap - #52

Merged
lynnlink merged 1 commit into
mainfrom
fix/renderer-build-heap
Oct 10, 2026
Merged

lynnlink merged 1 commit into
mainfrom
fix/renderer-build-heap

Conversation

@NiceCode666

Copy link
Copy Markdown
Contributor

Problem

The last Package run on main (824425b, run 37932191206) failed on both macOS jobs while Vite was transforming the renderer:

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
error: vite build exited with 134

The Windows job on the same commit passed, and the Package run on ci/windows-codesign (2046320, which predates #49) passed on all three platforms.

Cause

#49 added the Office editors (Univer presets, exceljs, mammoth, pptxgenjs, fabric, ...) and three new HTML entries. The renderer module graph is now 7118 modules, and Vite keeps all of it in memory during the transform phase.

Node's default old-space heap cap is ~2 GiB on 64-bit hosts with less than 16 GB of RAM, and V8 doubles it to 4 GiB only at 16 GB or more. The GitHub macOS runners have 7 GB (arm64) and 14 GB (Intel), so they get 2 GiB; the Windows runner has 16 GB and gets 4 GiB. That is the whole platform difference.

Validate does not run the production build, so #49 was green.

Fix

electron-build-renderer.ts passes --max-old-space-size=4096 to the Vite subprocess via NODE_OPTIONS. An explicit heap limit already present in the caller's NODE_OPTIONS is kept. Only the build subprocess is affected; the installed app's runtime heap is unchanged.

Validation

Local reproduction on main (Node 24, 24 GB host), vite build of the renderer with an explicit heap cap:

Heap cap Result Peak RSS
2048 MB exit 134, heap out of memory 2.2 GB
4096 MB 7118 modules, built in 46 s 3.5 GB

On this branch:

  • bun run test: 2710 pass, 6 skip, 0 fail (3 new tests cover the env construction)
  • bun run typecheck, bun run lint, bun run check:chinese: pass
  • bun run build end to end: pass, peak RSS 3.6 GB
  • Package dispatched on this branch with platform=all: see the run linked in the comments below

Relation to #51

#51 solves the same failure by building the four pages in separate Vite processes. Per its own description, the Excel page alone still needs a 4 GiB heap, so that approach also raises the limit while changing the output layout and duplicating shared dependencies across pages (34.8 MiB to 47.7 MiB of assets). This PR raises the limit alone and leaves the bundle as it is.

The Office editors (#49) grew the renderer module graph to 7k+ modules.
Vite keeps all of it in memory while transforming, and Node's default
old-space cap is ~2 GiB on hosts with less than 16 GB of RAM — the GitHub
macOS runners — so both macOS Package jobs died with "JavaScript heap out
of memory". The Windows runner has 16 GB, where V8 doubles the default to
4 GiB, which is why the same commit packaged fine there.

Pass --max-old-space-size=4096 to the Vite subprocess; peak RSS is ~3.5 GB
at 7118 modules, which fits the 7 GB arm64 runner. A caller that already
sets a limit in NODE_OPTIONS keeps it. Only the build subprocess is
affected, never the installed app.
@NiceCode666

Copy link
Copy Markdown
Contributor Author

Package run on this branch (platform=all, smoke=false, sign=false): https://github.com/bitsky-tech/bridgic-agent/actions/runs/37941736117

@NiceCode666

Copy link
Copy Markdown
Contributor Author

Result of https://github.com/bitsky-tech/bridgic-agent/actions/runs/37941736117 (platform=all, smoke=false, sign=false):

Job Vite renderer build Outcome
macOS arm64 7118 modules, built in 1m 47s fails later at notarization
macOS x64 / Intel 7118 modules, built in 2m 04s fails later at notarization
Windows x64 pass success

Both macOS jobs now get through the Vite build that killed the previous run on main, and through code signing of every embedded binary. They then fail in @electron/notarize:

HTTP status code: 403. A required agreement is missing or has expired.
This request requires an in-effect agreement that has not been signed or has expired.

That is an Apple Developer account state, not a build problem: the team's Account Holder has to accept the updated Program License Agreement at developer.apple.com (Agreements, Tax, and Banking). The Package run on ci/windows-codesign at 10:31 UTC today notarized fine with the same workflow, so the agreement changed after that. Once accepted, re-run the failed jobs to get a fully green run before merging.

@lynnlink
lynnlink merged commit 675a4c3 into main Oct 10, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants