Skip to content

fix(util): dial herdr's Windows named pipe instead of a TCP port - #231

Open
SandroHub013 wants to merge 1 commit into
live-mainfrom
fix/herdr-bridge-windows-pipe
Open

fix(util): dial herdr's Windows named pipe instead of a TCP port#231
SandroHub013 wants to merge 1 commit into
live-mainfrom
fix/herdr-bridge-windows-pipe

Conversation

@SandroHub013

@SandroHub013 SandroHub013 commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #230

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

socketOptions() passed the herdr socket path as a TCP port on Windows, so Node threw Port should be >= 0 and < 65536 before it opened anything. A nikcli pane never showed up as a herdr agent there.

herdr names its Windows pipe after the full .sock path, so the endpoint is \\.\pipe\C:\Users\...\herdr.sock — a path, not a host/port pair. Both platforms want { path }, so the branch collapses into one socketEndpoint() helper. It's exported because the wire-contract test's fake server was listening on the bare path too — that was the second half of the bug.

No behaviour change on macOS/Linux: socketEndpoint() returns the path unmodified there.

How did you verify your code works?

  • bun test packages/nikcli/test/plugin/herdr/report-protocol.test.ts on Windows 11: 1 pass / 9 fail → 10 pass. Whole packages/nikcli/test/plugin/herdr/ dir: 39 pass, 6 skip, 0 fail.
  • Against a live herdr server (0.8.0-preview): net.createConnection("\\\\.\\pipe\\" + HERDR_SOCKET_PATH) + session.snapshot returns real data; the old host/port form throws.
  • End to end: herdr pane get <id> on a nikcli pane reports "agent":"nikcli", "agent_status":"idle", and the pane appears in herdr agent list.

To see the old failure, check out live-main and run the same test file on Windows.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions github-actions Bot added needs:compliance size/S PR touches 12 lines labels Aug 18, 2026
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

}
return { path: socketPath }
export function socketEndpoint(socketPath: string): string {
return platform() === "win32" ? `\\\\.\\pipe\\${socketPath}` : socketPath

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style nit: the rest of packages/util/src uses process.platform === "win32" (see global.ts:14, filesystem.ts:57,78,228, win32.ts). The new helper introduces platform() from node:os, which means this file now mixes both styles. Consider process.platform === "win32" for consistency with the package, and the import { platform } from "node:os" line can be dropped.

export function socketEndpoint(socketPath: string): string {
  return process.platform === "win32" ? `\\\\.\\pipe\\${socketPath}` : socketPath
}

@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

socketOptions() returned `{ host: "\\.\pipe", port: socketPath }` on win32.
Node validates `port` as a number, so every bridge call threw "Port should be
>= 0 and < 65536" before opening a connection and a nikcli pane never appeared
as a herdr agent on Windows.

herdr names its pipe after the full .sock path, so the endpoint is
`\\.\pipe\C:\Users\...\herdr.sock` and both platforms want `{ path }`.

socketEndpoint() is exported so the wire-contract test listens on the same
endpoint the bridge dials; that suite went from 1 pass / 9 fail to 10 pass
on Windows.

Fixes #230
@SandroHub013
SandroHub013 force-pushed the fix/herdr-bridge-windows-pipe branch from da697b7 to 94cea4e Compare August 18, 2026 16:49
@github-actions

Copy link
Copy Markdown

lgtm

@SandroHub013

Copy link
Copy Markdown
Collaborator Author

Reopened — the compliance bot closed this before anyone looked at it, because the description was missing the template sections. Fixed and check-compliance is green now.

Rebased on live-main after #233 landed; the only conflict was the import line the two PRs share.

The 4 red checks are pre-existing, not from this change:

What this fixes: on Windows the herdr bridge threw Port should be >= 0 and < 65536 on every call and never opened a socket, so a nikcli pane never appeared as an agent. packages/nikcli/test/plugin/herdr/ goes from 33 pass / 9 fail to 42 pass / 0 fail there. No behaviour change on macOS or Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR touches 12 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

herdr bridge never connects on Windows: socketOptions passes the pipe path as a TCP port

1 participant