Skip to content

fix(process): exec and MCP servers fail with ENOENT after a Homebrew Node upgrade - #166222

Merged
steipete merged 5 commits into
openclaw:mainfrom
jayzhou2309:fix/relay-stable-node-path
Oct 7, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
jayzhou2309:fix/relay-stable-node-path

Conversation

@jayzhou2309

@jayzhou2309 jayzhou2309 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

After brew upgrade node removes the executable used by a running Gateway, exec calls and stdio MCP server startup can fail with spawn .../Cellar/node/<old>/bin/node ENOENT while the Gateway remains reachable.

User Impact

Command relays and the spawn broker can launch through the matching formula's stable Homebrew path after the old executable disappears. They keep the original executable while it exists. Restarting the Gateway after a Node upgrade still moves the Gateway itself onto the new runtime.

Why This Change Was Made

Both launch sites now use a shared synchronous resolver backed by the existing Homebrew candidate contract. It preserves the running executable until removal, then tries the formula's opt path and the unversioned formula's prefix bin path. It leaves non-Homebrew paths and the asynchronous service-install resolver's behavior unchanged.

The wrapper inventory additions are required: its existing broker-host root now eagerly imports the resolver and its normalization dependency. The inventory guard verifies this closure. Maintainer cleanup removes a redundant callback, shortens the new comment, makes the regression's worker URL portable on Windows, preserves the spawn mock's exports, and documents restart guidance.

Evidence

Current main still has both raw process.execPath launch sites (verified at 7880834c19616b5efb871e1755cd4b30cf2f2481). Their history traces to #150564; the earlier stable-path and stale-runtime diagnostics addressed other owners.

Final candidate: e2227954495d13976c5dffba489dce0b75b3dbb9.

  • Local static checks from a clean trusted main worktree: targeted oxfmt --check, node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <changed TypeScript files>, and git diff --check passed. Contributor code was not executed on the maintainer host.
  • Independent Codex review through P2 is clean after fixing the original test's Windows file-URL finding. ClawSweeper's existing PR review reported no actionable findings.
  • Isolated Linux AWS proof on lease cbx_7c15fdcb53af, bound to the final full SHA above: no instance role, no Tailscale, no hydration, Node 24.21.0. tsgo:core and all 35 tests across five files passed; combined wall time 52.33 s (test wrapper 35.57 s). The mock-export ratchet passed in 17.06 s. The targeted PR-wrapper inventory guard passed in 7.26 s.
pnpm tsgo:core && pnpm test src/infra/stable-node-path.test.ts src/process/spawn-broker/relay-integration.test.ts src/process/spawn-broker/startup.test.ts src/process/spawn-broker/restart.test.ts src/agents/mcp-stdio-transport.test.ts --maxWorkers=1
pnpm check:test-mock-exports --base c10679395819ede78bb073f979f95c157e165bfa
pnpm test test/scripts/eager-import-closure.test.ts -t 'PR wrapper inventory' --maxWorkers=1

On that same lease and head, only the three production files were restored to merge base c10679395819ede78bb073f979f95c157e165bfa; test files were preserved:

git checkout c10679395819ede78bb073f979f95c157e165bfa -- src/infra/stable-node-path.ts src/process/spawn-broker/host.ts src/process/spawn-broker/relay-integration.ts
pnpm test src/process/spawn-broker/relay-integration.test.ts -t 'launches the stable Homebrew Node' --maxWorkers=1

The negative control exited 1 in 22.08 s, failing the intended launch-path assertion at relay-integration.test.ts:94 (temporary prefix normalized):

AssertionError: expected last "vi.fn()" call to have been called with [ …(3) ]
- Expected: <tmp>/opt/node/bin/node
+ Received: <tmp>/Cellar/node/26.8.1/bin/node

Both this proof lease and the earlier baseline-generation lease cbx_85562ab9165f were stopped. Crabbox reported a stdout event-upload timeout after completion; the captured command output and successful run result supplied the evidence above.

LOC against the main merge base: production +22/-7 (net +15); tests +52/-2 (net +50); required tooling inventory +2/-0; retired test-mock baseline +0/-1; docs +7/-0. All non-test/non-doc files combined are +24/-8 (net +16). The production LOC exception is explicit: the distinct launch-time resolver and its two consumers require the remaining growth; no safe behavior-preserving deletion in these owner files was found to offset it. Maintainer cleanup removed six production lines from the contributor version without weakening lifecycle or launch checks.

The preceding head’s CI run passed all 24 selected Node test jobs but failed because the mock-export cleanup required pruning its retired baseline entry. The baseline was regenerated with its owning command on isolated AWS (10,580 → 10,579 entries), reviewed, and committed; no checks were weakened or rerun merely for green.

Test cost: combined five-file test wrapper 35.57 s; stable-node resolver shard 1.36 s (8 ms test bodies), process shard 27.07 s (relay test bodies 27 ms; includes broker siblings and 17.40 s cold worker preparation), MCP shard 3.46 s. The added relay regression itself took 3 ms. Final-head CI run 37556461876 completed successfully: 27 successful Node test jobs, 3010 aggregate runner seconds. These job totals include shared shard/setup cost, not per-file marginal cost.

Scope: this repairs the shared exec/MCP relay and broker startup/restart executable selection. Separate cached executable paths in Bun terminal discovery, SQLite worker launch, Chrome MCP normalization, and external MCP configuration need their own focused follow-ups. A real launchd-managed Homebrew upgrade was not exercised by this validation.

Original fix by @jayzhou2309; maintainer cleanup and isolated verification by @steipete. Contributor commits and credit are preserved.

Fixes #166170

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 9:22 PM ET / October 7, 2026, 01:22 UTC (Revision 4).

ClawSweeper review

What this changes

The PR lets command relays and the spawn broker use an available stable Homebrew Node path after their original executable disappears, with regression tests and troubleshooting documentation.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and the latest release retain the failing relay launch. The focused patch has sufficient production-path recovery proof, and no actionable correctness or security finding remains.

Priority: P1
Reviewed head: e2227954495d13976c5dffba489dce0b75b3dbb9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with convincing production-path recovery evidence and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured terminal results exercise the actual process supervisor and spawn broker after deleting their running Homebrew-shaped executable, showing successful command completion where before-fix runs failed with ENOENT. Real launchd brew upgrade was not exercised; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured terminal results exercise the actual process supervisor and spawn broker after deleting their running Homebrew-shaped executable, showing successful command completion where before-fix runs failed with ENOENT. Real launchd brew upgrade was not exercised; no stored-data contract changes.
Evidence reviewed 9 items Pinned introduced change: The merge-base-to-head diff changes executable selection at the relay and broker launch sites, reuses the existing Homebrew candidate contract, adds focused regressions and documentation, updates wrapper inventory, and removes a retired mock exception. Base-only changes were excluded.
Current main still needs the repair: The fetched main relay still passes process.execPath directly to spawnProcess; broker startup likewise directly spawns process.execPath. Its stable-path module has no launch-time recovery resolver.
Latest release retains the failing launch: The pinned v2026.9.8 relay source directly launches process.execPath. A local release-blob inspection failed; GitHub REST successfully supplied the same pinned release source.
Findings None None.
Security None None.

How this fits together

OpenClaw's process supervisor and MCP transport use a child relay to launch and manage local commands. The spawn broker provides an alternative process transport; both need an available Node executable to start their internal workers.

flowchart TD
  A[Exec tool requests] --> C[Process supervisor]
  B[MCP server startup] --> C
  C --> D[Child relay launch]
  D --> E[Select available Node executable]
  F[Spawn broker startup] --> E
  E --> G[Original executable or stable Homebrew path]
  G --> H[Managed child processes]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +15, Tests +50, Docs +7, Other +1. Total +73 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 22 7 +15
Tests 2 52 2 +50
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 2 2 1 +1
Total 8 83 10 +73

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #166170
Summary: This PR is the candidate repair for the remaining exec and MCP child-launch failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep runtime recovery at the shared process launch owners, preserving the original executable while available and using the established Homebrew candidates after removal.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: remove the Homebrew Cellar executable retained by a running Gateway, then request a new relay launch. Current main still passes that missing path directly; this read-only review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Reusing the existing formula-specific candidate contract at both internal launch sites is a focused repair that preserves working runtime selection and existing process ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 98567acd6060.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The linked official-release report shows exec and MCP startup breaking after a routine Homebrew Node upgrade.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured terminal results exercise the actual process supervisor and spawn broker after deleting their running Homebrew-shaped executable, showing successful command completion where before-fix runs failed with ENOENT. Real launchd brew upgrade was not exercised; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured terminal results exercise the actual process supervisor and spawn broker after deleting their running Homebrew-shaped executable, showing successful command completion where before-fix runs failed with ENOENT. Real launchd brew upgrade was not exercised; no stored-data contract changes.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff changes executable selection at the relay and broker launch sites, reuses the existing Homebrew candidate contract, adds focused regressions and documentation, updates wrapper inventory, and removes a retired mock exception. Base-only changes were excluded. (src/process/spawn-broker/relay-integration.ts:93, e2227954495d)
  • Current main still needs the repair: The fetched main relay still passes process.execPath directly to spawnProcess; broker startup likewise directly spawns process.execPath. Its stable-path module has no launch-time recovery resolver. (src/process/spawn-broker/relay-integration.ts:91, 98567acd6060)
  • Latest release retains the failing launch: The pinned v2026.9.8 relay source directly launches process.execPath. A local release-blob inspection failed; GitHub REST successfully supplied the same pinned release source. (src/process/spawn-broker/relay-integration.ts:20, fc23bc864e45)
  • Shared owner and bounded fallback: MCP startup reaches createOwnedStdioProcess and the POSIX child relay; anchored exec commands reach the same relay. The new resolver preserves an existing executable and otherwise checks formula-specific candidates from normalization-core, without arbitrary PATH search or changes to command admission and cleanup. (src/infra/stable-node-path.ts:22, e2227954495d)
  • Recorded real recovery proof: The captured PR body records runs under a copied Homebrew-shaped Node executable that was subsequently deleted. The actual process supervisor then returned exit 0 and stdout exec-ok; a separate run started the actual spawn broker after deletion and returned the same result through the broker. Before-fix controls produced ENOENT. This exercises both changed production launch owners; a real brew upgrade under launchd was explicitly not verified. Reported unit tests and checks are supplemental, and this review executed no target code. (e2227954495d)
  • Review continuity: The previous completed review reported no findings or published rank-up moves. Comparing its reviewed head with the current head shows only removal of the obsolete relay mock baseline entry; the partial mock now preserves real module exports. (config/test-mock-exports-baseline.txt, e2227954495d)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • LeonidasLux: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-06T17:49:57.655Z sha 13dd9ad :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T18:04:30.531Z sha 8e502f5 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-07T01:07:19.694Z sha 72b7711 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 6, 2026
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 7, 2026
@steipete
steipete merged commit f0c9bcf into openclaw:main Oct 7, 2026
156 of 157 checks passed
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…Node upgrade (openclaw#166222)

* test(process): cover relay launch after a Homebrew Node upgrade

* fix(process): launch stable Homebrew Node after a Cellar upgrade

* fix(process): add stable-node-path to the PR wrapper inventory

* fix(process): make Homebrew relay recovery regression portable

* test(process): prune retired relay mock exception

---------

Co-authored-by: Jay Zhou <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: After brew upgrade node, running Gateway spawns children from removed Cellar path (spawn ENOENT) until restart

2 participants