Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: socket file names are being truncated, and may become unremovable #13670

Closed
stelcheck opened this issue Jun 14, 2017 · 12 comments
Closed

net: socket file names are being truncated, and may become unremovable #13670

stelcheck opened this issue Jun 14, 2017 · 12 comments
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. net Issues and PRs related to the net subsystem.

Comments

@stelcheck
Copy link

stelcheck commented Jun 14, 2017

  • Version: 7.9.0, 8.1.1
  • Platform: macOS, Linux
  • Subsystem: net

Ref: https://gist.github.com/stelcheck/78c35a0a691de1e25a3a413519cc3fcb

When using a string that's about over 100 characters length, the file name being created will be truncated until it no longer shows up when doing a simple ls - which also means it may no longer be removable by hand.

This does not happen when using relative paths, only when using long absolute paths (I haven't tested the case when using long relative paths, e.g. '../hello/../hello/../etc...').

@stelcheck stelcheck changed the title net: socket files are being truncated, and may become unremovable net: socket file names are being truncated, and may become unremovable Jun 14, 2017
@stelcheck
Copy link
Author

Just tested on Linux and this does not appear to be an issue there.

@mscdex mscdex added macos Issues and PRs related to the macOS platform / OSX. net Issues and PRs related to the net subsystem. labels Jun 14, 2017
@gibfahn
Copy link
Member

gibfahn commented Jun 14, 2017

@addaleax @bnoordhuis is this to do with the 100 char socket length limit?

Refs: #12708 (comment)

Your path is > 100 characters long and might hit the BSD socket interface’s maximum length for UNIX socket paths…

Followon question, is this documented anywhere in node/libuv? I'd like to have something to refer people to if it comes up again.

@ronkorving
Copy link
Contributor

If it's an issue that we have no choice but to accept, it would be good to throw an exception instead of truncating the path.

@stelcheck
Copy link
Author

That is likely - although I seem to be able to create socket paths which are longer than 100 chars (maybe it doesn't include separators?).

The main issue is that the path is created, but potentially outside of the visible file system - so it can't be removed. So it would be a bit strange if underlying OS subsystems just decided to silently truncate in the case where there are limits...

@stelcheck
Copy link
Author

Ah, according to documentation the limit would be 104 chars on mac.

https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man4/unix.4.html

According to this SO, Linux has a limit too (108 chars): https://unix.stackexchange.com/a/367012

I just took the example I have posted above, and increased the path length, and indeed, Linux is affected as well. Updating the issue summary.

@addaleax
Copy link
Member

Fwiw, libuv v2 will fail with an error instead, but I’m not sure when that’s going to be released/included in Node.

@addaleax addaleax added libuv Issues and PRs related to the libuv dependency or the uv binding. and removed macos Issues and PRs related to the macOS platform / OSX. labels Jun 14, 2017
stelcheck added a commit to mage/mage-console that referenced this issue Jun 14, 2017
@mutantcornholio
Copy link
Contributor

Got this error it in production on linux.

Socket path gets truncated to 107 chars, socket does not remove on restart, program crashes on startup with EADDRINUSE.

@apapirovski
Copy link
Member

@addaleax Do you think we can do anything here? Document it for now perhaps?

@bnoordhuis
Copy link
Member

It's documented in the synopsis of the net module:

### Identifying paths for IPC connections

...
On UNIX, the local domain is also known as the UNIX domain. The path is a
filesystem pathname. It gets truncated to `sizeof(sockaddr_un.sun_path) - 1`,
which varies on different operating system between 91 and 107 bytes.
The typical values are 107 on Linux and 103 on macOS.
...

Looks like there's nothing else to do so I'll close this out.

@addaleax
Copy link
Member

If libuv 2 won’t be happening in time for Node 11, we could decide to throw an error in Node.js instead, I guess.

@bnoordhuis
Copy link
Member

I don't know if I'm in favor but I'm not opposed either.

@stelcheck
Copy link
Author

Throwing an error would be the safest behavior in my opinion. I doubt everyone's first reflex will be to open the doc if they run in this issue, so a descriptive runtime would most likely help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libuv Issues and PRs related to the libuv dependency or the uv binding. net Issues and PRs related to the net subsystem.
Projects
None yet
Development

No branches or pull requests

8 participants