-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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: Don't unlink unix socket on server.close() #19729
Comments
/cc @gireeshpunathil |
@laino - reading your 2 statements together
and
I get an impression that your use case is to start a new instance before (or while) the old one dies. My take is that, I am sure that is the case - scripts that monitor process PIDs determine when a process died and when to start a fresh one. However, I agree that if the process dies abruptly there is a chance of stale sockets and can block the automated way of restarting, but isn't it covered by deleting it before listing? Am I missing anything? In either case (common use case or rare) /cc @nodejs/http to review the proposal
Agree, this was reported and is being worked upon - nodejs/help#1080 and #19471 |
I don't think my initial explanation of this was very coherent. So please consider this simplified case where we start a new process, wait for it to become ready, and only then stop the old process:
Our Old process just unlinked our New socket! This problem is precisely why most existing software using unix sockets don't unlink |
@bnoordhuis, @indutny, @nodejs/streams |
I think this should be very sensible to do. At least adding an option to not close the socket. It would be great to review a PR. |
Unlinking the socket is unsmart, and does not correspond to the TCP behavior. |
Genius workaround @Lanio. |
Right now before an unix socket is closed its file is also unlinked by libuv. This behavior seems to go against the current docs, which explicitly mention that the socket would persist until unlinked (seems to imply this doesn't happen automatically).
This behavior has already been discussed multiple times in past, and every time the result
of the conversation appears to have been that it is a bad idea.
Some problems this behavior causes:
you would unlink the old socket in your new process immediately before listening to your new one.
However, if your old process calls
server.close()
afterwards, it will unlink your new socket. Bummer.server.close()
, however now you lose the abilityto wait for old connection to die before exiting, and also the ability to not accept new connections before
you exit.
The best way to work around this problem I've found so far appears to be this
safeListen
:The text was updated successfully, but these errors were encountered: