net: support AF_UNIX paths in net.BoundSocket#64399
Open
guybedford wants to merge 3 commits into
Open
Conversation
Collaborator
|
Review requested:
|
Signed-off-by: Guy Bedford <guybedford@gmail.com>
1e91371 to
6a4fee8
Compare
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.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64399 +/- ##
==========================================
- Coverage 90.25% 90.25% -0.01%
==========================================
Files 741 741
Lines 241207 241427 +220
Branches 45430 45495 +65
==========================================
+ Hits 217698 217892 +194
- Misses 15084 15090 +6
- Partials 8425 8445 +20
🚀 New features to boost your workflow:
|
Ethan-Arrowood
approved these changes
Jul 10, 2026
Ethan-Arrowood
left a comment
Contributor
There was a problem hiding this comment.
LGTM with just some doc changes and one question about the implementation.
| // rather than inferring pipe-ness from a path option on the connect call. | ||
| // Other pre-existing handles (e.g. a TLSWrap) are not transport handles, so | ||
| // fall back to the path option in that case. | ||
| const pipe = this[kBoundSource] ? this._handle instanceof Pipe : !!path; |
Contributor
There was a problem hiding this comment.
What happens here if this._handle is null from the if (this.destroyed) { line just before?
Contributor
Author
There was a problem hiding this comment.
Good catch! Yeah it would wrongly attempt a TCP connect - fixed to fall back to the path option if the handle is already gone.
3716f9f to
31a96f5
Compare
31a96f5 to
9571737
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.
Extends
net.BoundSocket(#63951) with apathoption 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 intoprocess.binding('pipe_wrap'), just as it replaces the need fortcp_wrapandudp_wrapsimilarly.pathis mutually exclusive withhost/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 throwsERR_INVALID_ARG_VALUE.address()returns the path string for a pipe (asServer.address()does), the address object for TCP.isPipegetter to tell the two apart.server.listen(bound)andnew net.Socket({ handle: bound }).connect()pick pipe vs TCP from the adopted handle's type.localAddress.Note two error codes match libuv rather than intuition: missing parent dir is
EACCES(libuv mapsENOENT), over-long path isEINVAL(UV_PIPE_NO_TRUNCATE).Tests cover sync bind +
address(), duplicate-bindEADDRINUSE, the listen/connect round-trip, bound-clientlocalAddress, the abstract namespace, and the error paths.