Skip to content

fix: replace nc -z -U probe with Node net.Socket.connect child process (PILOT-186)#2

Open
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-186-20260528-020900
Open

fix: replace nc -z -U probe with Node net.Socket.connect child process (PILOT-186)#2
matthew-pilot wants to merge 1 commit into
mainfrom
openclaw/pilot-186-20260528-020900

Conversation

@matthew-pilot
Copy link
Copy Markdown
Collaborator

Summary

Fixes PILOT-186: probeDaemonLiveSync in sdk-node/src/runtime.ts used BSD nc -z -U to check daemon liveness, but nc returns exit status 1 on macOS even for connectable UNIX sockets. This caused the seeder to falsely believe no daemon was running and potentially overwrite a live daemon binary.

Changes

  • Added import { spawnSync } from 'node:child_process' as a proper ESM import (the old code used inline require() which is unavailable in strict ESM).
  • Rewrote probeDaemonLiveSync to mirror the async probeDaemonLive path: it now spawns a synchronous Node child process that uses net.Socket.connect — the same cross-platform socket-connect semantics as the async probe.
  • Conservative fallback unchanged: if the child process cannot be spawned, falls back to existsSync(sockPath).

Files changed

  • src/runtime.ts: +25 / -8 lines in probeDaemonLiveSync, one new top-level import.

Testing

All 173 existing tests pass (vitest run), including the daemon-skip-branch tests in tests/runtime_extra.test.ts.

Ticket

🔗 https://vulturelabs.atlassian.net/browse/PILOT-186

…s (PILOT-186)

probeDaemonLiveSync used BSD nc(1) which returns exit 1 on macOS
even for connectable UNIX sockets. Combined with the ESM-incompatible
inline require('node:child_process'), this could cause the seeder to
falsely believe no daemon is running — and overwrite a live binary.

Mirror the async probe's net.Socket.connect approach via a synchronous
Node child process. This is consistent across platforms and avoids the
require-in-ESM hazard by importing spawnSync at the top of the module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant