Skip to content

fix(tui): pass --expose-gc as node argv instead of NODE_OPTIONS - #29998

Merged
teknium1 merged 3 commits into
mainfrom
hermes/hermes-504ac5c5
May 21, 2026
Merged

fix(tui): pass --expose-gc as node argv instead of NODE_OPTIONS#29998
teknium1 merged 3 commits into
mainfrom
hermes/hermes-504ac5c5

Conversation

@teknium1

@teknium1 teknium1 commented May 21, 2026

Copy link
Copy Markdown
Contributor

Salvage of #21711 by @YarrowQiao onto current main + sibling-site fix.

Summary

hermes --tui fails to start on Node versions that enforce the NODE_OPTIONS allowlist:

/usr/bin/node: --expose-gc is not allowed in NODE_OPTIONS

--expose-gc is not in Node's allowlist for NODE_OPTIONS (security: env-var-set flags must be safe to inject) and must be passed as a direct CLI flag. The fix moves it from the NODE_OPTIONS builder in _launch_tui() into the node argv built by _make_tui_argv(). --max-old-space-size=8192 stays in NODE_OPTIONS (it is allowlisted) so downstream node spawns inherit the heap cap.

Changes

  • hermes_cli/main.py — drop --expose-gc from NODE_OPTIONS, insert it as argv[1] on all three production node-launch paths (ext_dir, wheel-bundled, built tui_dir).
  • scripts/release.py — map yichengqiao21@gmail.comYarrowQiao for changelog attribution.

Sibling-site fix added during salvage

Original PR covered the ext_dir and tui_dir paths but missed the pip-wheel path (bundled). Without that, wheel installs would have lost --expose-gc entirely. Now all three sites are consistent.

Validation

Credit to @YarrowQiao — original commit preserved via cherry-pick.

Infographic

tui-expose-gc-fix

YarrowQiao and others added 3 commits May 21, 2026 13:00
Node refuses to start when NODE_OPTIONS contains --expose-gc:

    node: --expose-gc is not allowed in NODE_OPTIONS

NODE_OPTIONS is restricted to a small allowlist of flags that are safe
to inject via env (since any process able to set env vars on a node
child could otherwise enable arbitrary capabilities). --expose-gc is
not on that list and never has been -- it must be passed as a direct
CLI flag.

_launch_tui() was appending --expose-gc to NODE_OPTIONS before spawning
the TUI's node process, which made `hermes --tui` fail to start on
every modern node release. The intent (manual GC for long sessions to
avoid fatal-OOM) is preserved by inserting --expose-gc directly into
the node argv in _make_tui_argv() -- same effect, but actually allowed.

--max-old-space-size=8192 stays in NODE_OPTIONS: it *is* allowlisted,
and keeping it there means downstream node spawns inherit the same
heap cap without having to re-thread the flag through every spawn site.

The dev paths (`tsx src/entry.tsx` and `npm start` fallback) are left
alone -- they don't accept node flags directly, and the production
dist path is the one users actually hit via `hermes --tui`.

Repro before fix:

    $ hermes --tui
    /usr/bin/node: --expose-gc is not allowed in NODE_OPTIONS
The original PR fixed the ext_dir and built-tui paths but missed the
sibling pip-wheel path at line 1155. Without this, wheel installs would
lose --expose-gc entirely (the env-var append at the call site was
already removed). All three production node-launch sites now pass
--expose-gc via argv consistently.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-504ac5c5 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8995 on HEAD, 8995 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4750 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@teknium1
teknium1 merged commit 3d2f146 into main May 21, 2026
17 of 18 checks passed
@teknium1
teknium1 deleted the hermes/hermes-504ac5c5 branch May 21, 2026 20:10
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) P1 High — major feature broken, no workaround labels May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: hermes --tui fails with --expose-gc is not allowed in NODE_OPTIONS

3 participants