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
Open
fix: replace nc -z -U probe with Node net.Socket.connect child process (PILOT-186)#2matthew-pilot wants to merge 1 commit into
matthew-pilot wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes PILOT-186:
probeDaemonLiveSyncinsdk-node/src/runtime.tsused BSDnc -z -Uto check daemon liveness, butncreturns 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
import { spawnSync } from 'node:child_process'as a proper ESM import (the old code used inlinerequire()which is unavailable in strict ESM).probeDaemonLiveSyncto mirror the asyncprobeDaemonLivepath: it now spawns a synchronous Node child process that usesnet.Socket.connect— the same cross-platform socket-connect semantics as the async probe.existsSync(sockPath).Files changed
src/runtime.ts: +25 / -8 lines inprobeDaemonLiveSync, one new top-level import.Testing
All 173 existing tests pass (
vitest run), including the daemon-skip-branch tests intests/runtime_extra.test.ts.Ticket
🔗 https://vulturelabs.atlassian.net/browse/PILOT-186