Skip to content

fix(scripts): give typecheck and build the heap the server project needs - #106

Open
DeryFerd wants to merge 1 commit into
DuskBotAI:mainfrom
DeryFerd:fix/typecheck-heap
Open

DeryFerd wants to merge 1 commit into
DuskBotAI:mainfrom
DeryFerd:fix/typecheck-heap

Conversation

@DeryFerd

Copy link
Copy Markdown
Contributor

What and why

pnpm typecheck and pnpm build run tsc -b and tsc -p server/tsconfig.json under whatever heap Node hands them. On a machine whose default old-space cap is around 2 GB the server project outgrows it, and the run dies with exit 134 and "heap out of memory" before it prints a single type error, so the command that CONTRIBUTING and the development guide tell people to run cannot finish there. The packaging paths already raise the cap for the same work, with NODE_OPTIONS=--max-old-space-size=4096 in .github/workflows/release.yml and the same default in scripts/release-mac-local.sh, and the dev commands were the one place left without it.

scripts/typecheck.mjs runs both passes in one process with NODE_OPTIONS=--max-old-space-size=4096, keeps a larger value when the caller already set one, and stops at the first failing pass with that pass's exit code. package.json sends typecheck and build through it, so vite build still runs on its own once the types are checked. It is a small wrapper rather than NODE_OPTIONS=... tsc inside the script because VAR=value cmd is not a thing on Windows, and it spawns process.execPath with the resolved typescript/bin/tsc instead of a shell, which is the rule AGENTS.md and server/env-path.ts both set out.

How it was checked

pnpm typecheck on this branch: exit 0, nothing printed. The same command on an untouched checkout of main at 289ccb24 dies with exit 134 and FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory, and node -e "require('v8').getHeapStatistics().heap_size_limit" reports 2240 MB there, which is the ceiling it hits. As a control, NODE_OPTIONS=--max-old-space-size=4096 npx tsc -b on that same untouched checkout exits 0, so the heap is what decides the outcome.

pnpm exec vitest run scripts/typecheck.test.mjs passes with four tests: the heap it picks with and without NODE_OPTIONS already set, the two passes in order, and the early stop on the first failure. pnpm exec oxlint --deny-warnings over the files this branch touches reports no warnings and no errors.

  • New behaviour has a test
  • No secrets, personal data or local paths in the diff

Notes for reviewers

pnpm typecheck is what the static CI job runs, so that job gets the same heap from now on. Same checks, same verdict, more headroom.

I did not run the whole pnpm test suite here; the focused test above is the one I ran, and everything else is CI's to run.

Based on upstream main at 289ccb24, whose dev and main both still run the bare tsc pair. No rebase was needed.

pnpm typecheck and pnpm build ran tsc under Node's default old-space cap,
about 2 GB on a machine that reports less memory: the run died with exit 134,
"heap out of memory", before a single type error was printed. The packaged
builds already raise it for the same work; scripts/typecheck.mjs does the same
for the dev commands, in one process that runs both passes.
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.

1 participant