Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

domain sockets not cleaning up after themselves #3540

Closed
dshaw opened this issue Jun 26, 2012 · 7 comments
Closed

domain sockets not cleaning up after themselves #3540

dshaw opened this issue Jun 26, 2012 · 7 comments
Labels

Comments

@dshaw
Copy link

dshaw commented Jun 26, 2012

This one's pleasantly easy to reproduce:

var net = require('net');
var path = '/tmp/echo.sock';
var server = net.createServer(function(c) {
    console.log('server connected');
      c.on('end', function() {
            console.log('server disconnected');
              });
        c.write('hello\r\n');
          c.pipe(c);
});
server.listen(path, function() {
    console.log('server bound on %s', path);
});

Running this more than once will throw Error: listen EADDRINUSE. The file system artifact is not getting cleaned up.

@dshaw
Copy link
Author

dshaw commented Jun 26, 2012

My original gist: https://gist.github.com/9f93cdcd3a77b9142e51

@bnoordhuis
Copy link
Member

That's by design. Older versions of node used to unlink the socket but that was subject to heinous race conditions in multi-process setups.

I realize that's never been documented on the API changes page. Well, it is now. :-)

@piscisaureus
Copy link

@bnoordhuis Does the socket file get removed when you close() the server, or when node gracefully exits?

@bnoordhuis
Copy link
Member

@piscisaureus server.close() unlinks the socket (which perhaps isn't a great idea, either), process.exit() or throw 42 won't.

@piscisaureus
Copy link

@bnoordhuis Yeah, that will break in a cluster scenario.

@aslilac
Copy link

aslilac commented Jul 11, 2012

@bnoordhuis Could a note of this behavior be added to the regular documentation as well?

@dayuoba
Copy link

dayuoba commented Apr 12, 2015

I got the same problem,i do not know why that was by design that node won't unlink path when exit in any case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants