Files
orca/config/ast-grep/rules/main-worker-thread-spawn.yml
Neil 99e75ebdde fix(orcad): stop the managed server crash-looping under a ulimit -v address-space limit (#38263)
* fix(orcad): fit orcad inside a `ulimit -v` address-space limit

On hosts that cap virtual memory (ulimit -v 8 GiB on an HPC node), the
managed orcad crash-looped with "Failed to reserve virtual memory for
CodeRange" whenever it started a worker thread.

Two reservations used up the limit:
- undici's WASM HTTP parser, loaded by the first fetch, reserves a
  trap-handler guard region (4-9 GiB). The pinned-Node orcad launch now
  passes --disable-wasm-trap-handler --wasm-max-mem-pages=1024.
- each Worker isolate reserves V8's default CodeRange (512 MB on x64,
  ~600 MB of address space per worker). Main-process workers now go
  through spawnWorkerThread(), which caps the code range at 64 MB, and
  a lint rule keeps new sites on it.

Fixes #37538. Thanks to lin-tianyu for the report and logs.

* fix(orcad): keep the runtime selector one command; enforce spawnWorkerThread with ast-grep

Refs #37538

* test(orcad): run the address-space regression on Node

Refs #37538

* docs(orcad): note the WASM memory cap at the pinned-Node flags

Refs #37538
2026-11-04 17:00:52 -08:00

32 lines
1.1 KiB
YAML

# Main-process workers must cap their code range; only the spawn helper constructs them.
# The TSX document below mirrors the TypeScript one; keep them in sync.
id: main-worker-thread-spawn
language: typescript
severity: error
message: A default Worker reserves V8's full CodeRange (~600 MB of address space on x64) and crashes `ulimit -v` hosts (#37538). Use spawnWorkerThread() from src/main/worker-threads/worker-thread-spawn.ts.
files:
- src/main/**
ignores:
- '**/*.test.*'
- '**/*.test-fixtures.*'
- src/main/worker-threads/worker-thread-spawn.ts
rule:
any:
- pattern: new Worker($$$)
- pattern: new $NS.Worker($$$)
---
id: main-worker-thread-spawn-tsx
language: tsx
severity: error
message: A default Worker reserves V8's full CodeRange (~600 MB of address space on x64) and crashes `ulimit -v` hosts (#37538). Use spawnWorkerThread() from src/main/worker-threads/worker-thread-spawn.ts.
files:
- src/main/**
ignores:
- '**/*.test.*'
- '**/*.test-fixtures.*'
- src/main/worker-threads/worker-thread-spawn.ts
rule:
any:
- pattern: new Worker($$$)
- pattern: new $NS.Worker($$$)