fix(cli): strip supervisor node IPC channel vars from spawned node envs #139582
All Vouch review confidence checks passed
Residual risk 0.35 = Change Risk (0.59) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #139582"
general
weight: 0.35
PRATHAMESH75
What does this PR do?
When the dashboard runs under a fork-mode supervisor like pm2, the supervisor injects
NODE_CHANNEL_FD/NODE_CHANNEL_SERIALIZATION_MODEinto the Python process it manages. Every node child the dashboard then spawns — the chat PTY's TUI entry, thefreshness.mjsprobe,node-deps.mjs— inherits those variables, sees a node IPC channel is declared, and tries to adopt the named fd. Python spawns with the defaultclose_fds=True, so that fd is already closed in the child and its number gets reused by node's own internals (eventfd/epoll); libuv registers it twice and aborts at exit (uv__io_poll ... Assertion errno == EEXIST, SIGABRT). The user-visible symptom in #139556 is the Chat page stuck on "connection interrupted, reconnecting…" forever (PTY dies before writing its session file), plus thousands of aborts in the pm2 error log.Hermes never makes its children IPC-channel peers of an external supervisor, so the two channel variables have no valid meaning in any child env this repo builds. This PR strips them at the two child-env exits every affected spawn flows through:
hermes_cli/web_server_chat.py_resolve_chat_argv— the chat PTY env (PtyBridge.spawnconsumes it verbatim).pm/package.pycompose_env— the single composition exit behindpm.env_for("node")(thefreshness.mjsprobe) andensure("npm", ...).env(thenode-deps.mjs/ build chain).build_subprocess_envitself is deliberately left byte-preserving on its no-scrub path (its existing contract, locked bytest_no_scrub_is_byte_preserving_except_explicit_extra); the strip happens at the dashboard caller where the node-child policy belongs.Related Issue
Fixes #139556
Type of Change
Changes Made
hermes_cli/web_server_chat.py:_resolve_chat_argvpopsNODE_CHANNEL_FD/NODE_CHANNEL_SERIALIZATION_MODEfrom the chat PTY env before it is returned to the spawn site.pm/package.py:compose_envpops the same two variables right after the base snapshot, so every PM-composed child env (node/npm probes and builds) is clean.tests/hermes_cli/test_web_server_profile_unification.py: regression test —_resolve_chat_argvmust not carry the supervisor's channel vars.tests/pm/test_pm_core.py: regression test —compose_envstrips the channel vars both from abasedict and from theos.environsnapshot pathenv_for("node")uses.How to Test
1.
uv run pytest tests/pm/test_pm_core.py::test_compose_env_strips_node_ipc_channel_vars "tests/hermes_cli/test_web_server_profile_unification.py::TestProfileScopedChatPty" tests/tools/test_build_subprocess_env.py -q— Observed result: 14 passed (new tests included; the byte-preserving no-scrub contract still passes).2.
uv run pytest tests/pm/test_pm_core.py tests/hermes_cli/test_source_build.py tests/hermes_cli/test_web_server_pty_reconnect.py tests/hermes_cli/test_pty_keepalive_ws.py tests/hermes_cli/test_web_server_pty_idle_backoff.py -q— Observed result: 58 passed, 12 skipped (environment-dependent skips), 0 failed.3. Manual equivalent of the production path:
NODE_CHANNEL_FD=13 node -e '0'aborts with the libuvEEXISTassertion (per #139556); with this change the dashboard-built child envs no longer contain the variable, so the spawned node processes are unaffected by the supervisor's leftover channel vars.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass (targeted suites: the pm core, source-build, PTY/chat env suites listed under How to Test — all green)python scripts/checkpasses (the blocking lint and code-health checks CI runs) (ruff/format green on the touched files; blob-size/health could not be evaluated faithfully in the local shared-object clone and are left to CI)Documentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A — this is a bug fix, no skill added.
Screenshots / Logs
N/A — env-level fix; the reproduction and libuv assertion output are documented in #139556.