test: Added relative path to accommodate limit#12601
test: Added relative path to accommodate limit#12601b6t wants to merge 3 commits intonodejs:masterfrom b6t:net-connect-options-fd-bug
Conversation
Found that libuv had a path character limit of 108. Used path.relative() to set prefix with relative path.
Trott
left a comment
There was a problem hiding this comment.
LGTM if CI is green. Thanks for fixing this!
|
I think there should be a comment above the change the describes why a relative path is being used (including libuv error and platform (if error is specific to say Windows filesystems or something)). |
| { | ||
| const prefix = `${common.PIPE}-net-connect-options-fd`; | ||
| const prefix = path.relative(`${common.PIPE}-net-connect-options-fd`, | ||
| `${__dirname}-net-connect-options-fd`); |
There was a problem hiding this comment.
I think this should be this instead:
const prefix = path.relative('.', `${common.PIPE}-net-connect-options-fd`);Simpler, and I think it will fix the problems we're seeing on CI.
Trott
left a comment
There was a problem hiding this comment.
I think it needs a tweak in the path.relative() call. See comment.
|
ping @coreybeaumont … do you think you could address @Trott’s comment? |
|
Apologies @Trott I missed that note. I'll take of this today. |
Improved the call to path.relative(). Also added comments explaining the use of a relative path.
| const prefix = path.relative(`${common.PIPE}-net-connect-options-fd`, | ||
| `${__dirname}-net-connect-options-fd`); | ||
| // Using relative path on osx if the path is greaterthan 108 chars | ||
| // an AssertionError: -48 is thrown |
There was a problem hiding this comment.
nit: might be worthwhile adding a comment that explains what -48 means.
There was a problem hiding this comment.
I believe -48 is the libuv error for UV_EADDRINUSE. In any event, it's a libuv error.
I don't think this is OS X specific. It will happen on anything (or at least anything POSIX?) with a long enough path. I think you can just remove the comment (no one's going to wonder "why aren't they using an absolute path here??!!") or use a comment like this:
// Use relative path to avoid hitting 128-char length limit for socket paths in libuv.
/cc @addaleax to make sure I got that right (that it's 128 chars, that it's in libuv, etc.).
There was a problem hiding this comment.
@Trott 108 should be the right number on Linux and almost certainly other systems too¹², quote unix(7):
struct sockaddr_un {
sa_family_t sun_family; /* AF_UNIX */
char sun_path[108]; /* pathname */
};It’s this bit of code in libuv that truncates the path to that size. The actual value for EADDRINUSE is OS-dependent; for example, for me on Linux it’s 98 (which libuv forwards as -98).
See also #12708, I think that’s the same kind of problem.
¹ edit: yeah, your guess of “anything POSIX” sounds right, Windows doesn’t have UNIX sockets. ;)
² more edits: https://nodejs.org/api/net.html#net_server_listen_path_backlog_callback has numbers, it’s somewhere between 92 and 108.
Altered to comment to better reflect the use of a relative path.
Fail with ENAMETOOLONG when the name of a Unix socket exceeds `sizeof(saddr.sun_path)`. Previously the path was just truncated, which could result in nasty bugs, and even though that behaviour has been always been around, it’s hard to imagine a situation in which ending up with an incorrect path is better than not creating a socket at all. Ref: nodejs/node#12601 Ref: nodejs/node#12708
Fail with ENAMETOOLONG when the name of a Unix socket exceeds `sizeof(saddr.sun_path)`. Previously the path was just truncated, which could result in nasty bugs, and even though that behaviour has been always been around, it’s hard to imagine a situation in which ending up with an incorrect path is better than not creating a socket at all. Ref: nodejs/node#12601 Ref: nodejs/node#12708
Found that libuv had a path character limit of 108. Used path.relative() to set prefix with relative path. Also added comments explaining the use of a relative path. PR-URL: nodejs#12601 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
|
Landed in 0101a8f. |
Fail with ENAMETOOLONG when the name of a Unix socket exceeds `sizeof(saddr.sun_path)`. Previously the path was just truncated, which could result in nasty bugs, and even though that behaviour has been always been around, it’s hard to imagine a situation in which ending up with an incorrect path is better than not creating a socket at all. Refs: nodejs/node#12601 Refs: nodejs/node#12708 PR-URL: #1329 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
|
Should land with #11847 if that is backported. |
Found that libuv had a path character limit of 108. Used path.relative() to set prefix with relative path.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)