fix(one): use a named pipe for the daemon IPC socket on Windows#725
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
fix(one): use a named pipe for the daemon IPC socket on Windows#725YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
`one daemon` binds its CLI<->daemon control channel with net.Server.listen(SOCKET_PATH). On Windows, Node implements local-domain sockets as named pipes and the path must live under \.\pipe\, so a filesystem ~/.one/daemon.sock path is rejected with EACCES — which surfaced as an uncaught server 'error' event and crashed the command on start. Select each platform's native local-IPC primitive (the same approach VS Code, Nx, pm2 and Nuxt's vite-node use): keep the AF_UNIX socket file on POSIX, use a named pipe on Windows. The pipe name is a deterministic per-user hash so the daemon and the CLI derive the same name independently and distinct users don't collide in the machine-global pipe namespace. Preserves the existing owner-only intent (chmod 0600 on the POSIX socket, now guarded since it doesn't apply to a Windows pipe), drops the fs.existsSync(SOCKET_PATH) precheck on Windows (a named pipe is not a filesystem entry), and adds a server 'error' handler so a bind failure reports actionably instead of crashing. Validated on Windows 11: the named-pipe endpoint binds and round-trips (ping/pong) where the .sock path returned EACCES.
40ca140 to
77ce259
Compare
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
one daemoncrashes immediately on Windows. The CLI↔daemon control channel binds a local socket withnet.Server.listen(SOCKET_PATH), whereSOCKET_PATHis~/.one/daemon.sock. On Windows, Node implements local-domain sockets as named pipes, and the path must live under\\.\pipe\— so a filesystem.sockpath is rejected withEACCES. BecausecreateIPCServerhad noserver.on('error')handler, that surfaced as an uncaught'error'event and crashed the command on start:Fix
Select each platform's native local-IPC primitive behind one helper, keeping the existing hand-rolled
netserver and the owner-only model:~/.one/daemon.sock, stillchmod 0600(now guarded, sincechmoddoesn't apply to a Windows pipe). Theelsebranch is the original code path.isDaemonRunningno longer pre-checksfs.existsSync(SOCKET_PATH)on Windows (a named pipe is not a filesystem entry, so the check always returned false and the daemon read as "not running"); it probes by connecting.server.on('error')handler so a bind failure reports an actionable message instead of crashing.This is the standard approach for a fixed-name local daemon socket — keep the socket, pick the OS-native primitive. It matches Node's own
netdocs ("On Windows, the local domain is implemented using a named pipe … the path must refer to an entry in\\?\pipe\or\\.\pipe\"), Nuxt (packages/vite/src/plugins/vite-node.ts), the OpenSSH agent ($SSH_AUTH_SOCK↔\\.\pipe\openssh-ssh-agent), VS Code (createStaticIPCHandle), Nx, and pm2.Test plan
Validated on Windows 11 (Node 25):
one daemon→ uncaughtEACCESonlisten ~/.one/daemon.sock.ping/pong) where the.sockpath failed.oxlintandoxfmt --checkclean on the changed file;tsc --noEmitreports no errors in it.Note on CI
The
testsjob exercises this change. Thechecksjob's Security Audit step is currently red on a pre-existing, repo-wide advisory unrelated to this PR —hono <4.12.25(GHSA-88fw-hqm2-52qc,honois pinned to4.12.5in rootresolutions), which also fails onmainand is not in the workflow's--ignorelist. It clears whenhonois bumped; nothing in this PR touches it.