joyent/node — pull request #2688 by SaltwaterC (2012-02-03 16:33:49+00:00)
Title: The net.js client does not release the socket on DNS errors

Which means that the socket stays there forever and the event loop waits for a connection that is not going to happen. The http.js client is patched against this behavior, but the issue lies within net.js.

A simple script to reproduce it:

```javascript
var net = require('net');
var socket = net.connect(80, '.foo.bar', function () {
console.log('connected');
socket.destroy();
});
socket.on('error', function (err) {
console.error(err);
});
```

The result is simple: the process hangs.

This small patch makes sure of that it is destroyed when the deferred error event is sent. Also added a specific test for this issue. I also corrected the http-dns-error error test that didn't test the https.js specifically because this bug.