joyent/node — Issue #2735: net.connect() keeps event loop alive on ENOENT
Author: mscdex
Created: 2012-02-10 20:56:53+00:00
State: open

I was curious as to why the event loop is kept alive when a socket gets ENOENT when trying to connect (to an invalid hostname). I noticed this happening on both Windows and Linux. All other reproducible errors such as connecting to a valid hostname but invalid port, etc. do not keep the event loop alive.

Here's the code in question:

```javascript
var net = require('net');
var s = new net.Socket();
s.on('error', function(err) {
// err === "Error: getaddrinfo ENOENT"
console.error('Error occurred: ' + err);
});
s.connect(1337, 'someinvalidhostname');
```