Skip to content

net: Fixing error message

When I was trying to understand the problem in https://github.com/nodejs/io.js/issues/1924, I found out that we show error messages like this

Error: connect EMFILE 127.0.0.1:8888 - Local (undefined:undefined)

It is because, we ran out of file descriptors and we don't have a valid socket. So, if the return value of _getsockname doesn't have valid address and port properties, we just don't include them in the error message.


The problem can be reproduced with the following code

var net = require('net');

// Server
net.createServer().listen(8888, function () {
    console.log('server bound');
});

console.log('Launched');

// Connect to server
for (var i = 0; i < 10000; i++) {
    net.connect({
        port: 8888
    });
}

cc: @bnoordhuis

Merge request reports

Loading