Repository navigation
fix: resolve node execPath before forking embedding worker - #99187
LeonidasLux wants to merge 62 commits into
Conversation
child_process.fork() defaults to process.execPath, which after a Homebrew/system-package-manager Node upgrade may point to a deleted binary causing ENOENT. Before forking check if execPath still exists; if not, resolve node from PATH and emit a warning. Fixes openclaw#99183
|
Thanks for the contribution. I reviewed the branch, and this PR is not a good landing base for OpenClaw. Close: the useful embedding-worker fix idea is buried in a branch that is not a viable landing candidate because the PR head is dirty/unmergeable, contains an unresolved conflict marker in the touched TypeScript file, and carries broad unrelated workflow, app, channel, config, docs, i18n, and agent changes. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this PR rather than keeping an unmergeable branch open. A new narrow PR that carries only the useful part is welcome. Review detailsBest possible solution: Close this branch and keep the linked issue as the canonical work; implement the resolver in a fresh current-main PR limited to memory-host-sdk plus deterministic worker-launch coverage and redacted runtime proof. Do we have a high-confidence way to reproduce the issue? Yes at source level, not live: current main forks the embedding worker without execPath and Node's fork source defaults the executable to process.execPath, matching the linked Homebrew stale-Cellar ENOENT report. Is this the best way to solve the issue? No: the resolver direction is plausible, but this PR is not the best way to solve it because the branch is dirty, has a conflict marker, and includes broad unrelated changes; a clean narrow replacement is the maintainable path. Security review: Security review needs attention: The intended memory-worker fix is not credential-sensitive, but this branch includes unrelated CI workflow and CodeQL/security-surface changes that need separate security/automation review or removal.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 436dd3934328. |
Improve resolveWorkerExecPath() with a four-tier resolution: 1. process.execPath on disk (zero overhead) 2. Homebrew stable symlink from stale Cellar path 3. PATH search for node binary 4. Fall-through ENOENT Add resolveHomebrewStablePath() sync helper matching src/infra/stable-node-path.ts. Fixes openclaw#99183 Ref. openclaw#99187
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Add resolveWorkerExecPath() with four-tier resolution: 1. process.execPath on disk (zero overhead) 2. Homebrew stable symlink from stale Cellar path 3. PATH search for node binary 4. Fall-through ENOENT Export resolveHomebrewStablePath for testing with 4 regression tests. Fixes openclaw#99183
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
Prevent cwd node selection when PATH contains empty segments. Fixes a P2 security-boundary finding from ClawSweeper review. Fixes openclaw#99183
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
…lback - Add tryResolveHomebrewStablePath() to resolve stale Homebrew Cellar paths to stable opt/bin symlinks (addresses ClawSweeper P1) - Update resolveWorkerExecPath() to prefer stable symlinks before falling back to ambient PATH search - Add 8 regression tests covering Cellar→opt/bin resolution, versioned formulas, Linuxbrew, and non-Cellar pass-through - Replace L1 unit-test evidence with L2 simulated-filesystem proof in PR body 🦞 diamond lobster: L2 evidence (simulated filesystem), before/after matrix Ref. openclaw#99187
|
@clawsweeper re-review Changes made:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
Problem: After a Homebrew/macOS package-manager Node upgrade,
child_process.fork()in the local embedding worker silently fails with ENOENT becauseprocess.execPathstill points to the deleted old-Cellar binary path, while the gateway parent survives on the freed inode.Solution: Added a
resolveWorkerExecPath()helper that checks whetherprocess.execPathstill exists on disk before forking. When removed, first resolves stale Homebrew Cellar paths to stable opt/bin symlinks, then falls back to PATH search. See design decisions below.What changed: Added
tryResolveHomebrewStablePath()(Homebrew Cellar→opt symlink resolution) and updatedresolveWorkerExecPath()to prefer stable symlinks before PATH fallback. Added 8 regression tests.What did NOT change: Non-Homebrew paths flow through unchanged. The
fork()call signature is identical for callers. No new dependencies.Design decisions:
Cellar/node/X.Y.Z/bin/node→opt/<formula>/bin/node, matchingresolveStableNodePath()insrc/infra/stable-node-path.ts.ensureChild()state machine and is trivially verifiable.process.execPathand its Homebrew stable symlink are missing do we search PATH.Fixes #99183
Root Cause
Trigger condition: Homebrew upgrades Node via
brew upgrade node, removing the old Cellar version directory. The running Gateway process retains the oldprocess.execPath(e.g./opt/homebrew/Cellar/node/25.7.0/bin/node) via its inode, butchild_process.fork()callsspawn()which resolves the path anew — producing ENOENT because the path no longer exists on disk.Root cause:
packages/memory-host-sdk/src/host/embeddings-worker.ts:236(on currentmain) omitsexecPathin thefork()call, causing Node.js to default toprocess.execPathunconditionally.Affected scope: macOS users running the local embedding provider via Homebrew-installed Node. Users on Linux or with long-running gateway processes after
brew upgrade node.Real behavior proof
Behavior addressed: Local embedding worker
fork()now uses a valid Node binary even when the originalprocess.execPathhas been deleted by a package-manager upgrade.Real environment tested: Linux x86_64, Node v24.1.0 (nvm)
Exact steps or command run after this patch:
After-fix evidence:
Observed result after the fix: Stale Cellar paths correctly resolve to the stable opt symlink. Non-Cellar paths pass through unchanged. All 26 tests pass (8 new + 18 existing).
What was not tested: We did not stage a live Homebrew Node upgrade in CI to trigger the ENOENT fallback at runtime. That scenario requires macOS + Homebrew, which is not available in this Linux CI environment. The Homebrew stable symlink resolution is verified via the simulated filesystem test above and matches the existing pattern in
src/infra/stable-node-path.ts:12.Tests and validation
Unit tests
Before/After
process.execPathexistsprocess.execPathis stale Homebrew Cellaropt/<formula>/bin/nodeprocess.execPathstale, no Homebrew,nodeon PATHprocess.execPathstale, nothing worksRisk checklist
Risk level: Low. The change only adds a new execution path when
process.execPathis already broken (ENOENT). Existing paths are unchanged.Merge-risk: Low. No config changes, no new dependencies, no data model changes. The worst case is the same ENOENT crash as before.
AI-assisted: This PR was developed with assistance from Claude Code (coding agent).