Skip to content

net: support AF_UNIX paths in net.BoundSocket - #64399

Closed
guybedford wants to merge 5 commits into
nodejs:mainfrom
guybedford:net-boundsocket-pipe
Closed

net: support AF_UNIX paths in net.BoundSocket#64399
guybedford wants to merge 5 commits into
nodejs:mainfrom
guybedford:net-boundsocket-pipe

Conversation

@guybedford

Copy link
Copy Markdown
Contributor

Extends net.BoundSocket (#63951) with a path option so it can immediately bind a named unix-domain socket (or Windows pipe) synchronously, not just TCP. This gives a public synchronous UDS bind through the same role-neutral handle, instead of reaching into process.binding('pipe_wrap'), just as it replaces the need for tcp_wrap and udp_wrap similarly.

path is mutually exclusive with host/port/ipv6Only/reusePort, and binds in the constructor so conflicts throw there like TCP does. A leading '\0' uses the Linux abstract namespace; an abstract path elsewhere throws ERR_INVALID_ARG_VALUE.

  • address() returns the path string for a pipe (as Server.address() does), the address object for TCP.
  • New isPipe getter to tell the two apart.
  • server.listen(bound) and new net.Socket({ handle: bound }).connect() pick pipe vs TCP from the adopted handle's type.
  • A bound client pipe reports its source path as localAddress.

Note two error codes match libuv rather than intuition: missing parent dir is EACCES (libuv maps ENOENT), over-long path is EINVAL (UV_PIPE_NO_TRUNCATE).

Tests cover sync bind + address(), duplicate-bind EADDRINUSE, the listen/connect round-trip, bound-client localAddress, the abstract namespace, and the error paths.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. labels Jul 10, 2026
@guybedford
guybedfordforce-pushed the net-boundsocket-pipe branch from 1e91371 to 6a4fee8CompareJuly 10, 2026 00:24
@codecov

codecovBot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.93878% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.14%. Comparing base (db3a8d8) to head (f30b9ca).
⚠️ Report is 40 commits behind head on main.

Files with missing linesPatch %Lines
lib/net.js96.93%3 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #64399 +/- ##
=======================================
Coverage 90.14% 90.14% =======================================
Files 741 741 Lines 242133 242221 +88 Branches 45568 45584 +16 =======================================
+ Hits 218265 218360 +95 
Misses 15371 15371 + Partials 8497 8490 -7 
Files with missing linesCoverage Δ
lib/net.js94.43% <96.93%> (+0.06%)⬆️

... and 27 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with just some doc changes and one question about the implementation.

Comment threaddoc/api/net.md
Comment threaddoc/api/net.md
Comment threaddoc/api/net.md Outdated
Comment threadlib/net.js Outdated
@guybedford
guybedfordforce-pushed the net-boundsocket-pipe branch 3 times, most recently from 9571737 to 3429149CompareJuly 16, 2026 01:18
Comment threaddoc/api/net.md Outdated
Comment threadlib/net.js Outdated

@jasnelljasnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Couple of nits but otherwise LGTM

@guybedford
guybedfordforce-pushed the net-boundsocket-pipe branch from 542c603 to 6472cd1CompareJuly 20, 2026 22:45
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Signed-off-by: Guy Bedford <guybedford@gmail.com>
Only trust the adopted handle's type when it came from a BoundSocket;
a TLSSocket's _handle is a TLSWrap, not a Pipe, so TLS/HTTPS over pipes
must still infer pipe-ness from the path option.
@guybedford
guybedfordforce-pushed the net-boundsocket-pipe branch from 6472cd1 to f30b9caCompareJuly 21, 2026 18:12
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mcollinamcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 22, 2026
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 22, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@Ethan-ArrowoodEthan-Arrowood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FYI this is blocked by the broken test-internet workflow affecting a number of PRs right now. Once #64624 lands this will be good to go.

@Ethan-ArrowoodEthan-Arrowood added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 24, 2026
@Ethan-Arrowood

Copy link
Copy Markdown
Contributor

64624 landed; requested a fresh CI run

@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 24, 2026
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@guybedfordguybedford added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed needs-ci PRs that need a full CI run. labels Jul 24, 2026
guybedford added a commit that referenced this pull request Jul 24, 2026
Signed-off-by: Guy Bedford <guybedford@gmail.com>
PR-URL: #64399
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@guybedford

Copy link
Copy Markdown
ContributorAuthor

Landed in b420cb6.

@guybedfordguybedford removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jul 24, 2026
@guybedford
guybedford deleted the net-boundsocket-pipe branch July 24, 2026 23:46
aduh95 pushed a commit that referenced this pull request Aug 3, 2026
Signed-off-by: Guy Bedford <guybedford@gmail.com>
PR-URL: #64399
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 4, 2026
Signed-off-by: Guy Bedford <guybedford@gmail.com>
PR-URL: #64399
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 6, 2026
Signed-off-by: Guy Bedford <guybedford@gmail.com>
PR-URL: #64399
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

netIssues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@guybedford@nodejs-github-bot@Ethan-Arrowood@mcollina@jasnell