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

impossible unix domain socket error #28947

Closed
ORESoftware opened this issue Aug 3, 2019 · 2 comments
Closed

impossible unix domain socket error #28947

ORESoftware opened this issue Aug 3, 2019 · 2 comments

Comments

@ORESoftware
Copy link
Contributor

ORESoftware commented Aug 3, 2019

I am on Node.js 12 on linux. This code is working on my Mac, so definitely some discrepancies between the machine and or the libraries used for linux or something.

So I have this:

const udsFile = '/home/oleg/.bunion/sockets/1564793353887444414.sock';

try {
    fs.unlinkSync(udsFile);
}
catch (e) {
    console.error(e);  // Error: ENOENT: no such file or directory, unlink '/home/oleg/.bunion/sockets/1564793353887444414.sock'  (this is fine)
}

server.listen(udsFile, () => {   // synchronously raised error here

    console.log('Listening on unix domain socket:', udsFile);

});

and then I get this synchronous error which is raised synchronously when server.listen is called:

Error: listen EADDRINUSE: address already in use /home/oleg/.bunion/sockets/1564793353887444414.sock

this makes no sense..my only guess is that the server.listen API is different on Mac vs Linux?

Another thing - server.listen doesn't seem to be async here, the error that's raised is synchronous, so that seems like a weird thing in Node.js-land?

@ORESoftware
Copy link
Contributor Author

update, so it doesn't appear that the error is raised synchronously - and when I added this:

server.on('error', e => {
  consumer.warn(e);
});

now it seems to work? very strange

@ORESoftware
Copy link
Contributor Author

so what was happening is that more than one process was trying to create the file and one was failing, the other was succeeding, my mistake :(

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

No branches or pull requests

1 participant