mcavage/node-restify — pull request #494 by rysenko (2013-12-10 10:02:10+00:00)
Title: Fix connecting socket detection

I'm using node v0.10.22 and connectTimeout in restify isn't taken into account is some cases. Example:

var restify = require('restify');
var client = new restify.createJSONClient({url: 'https://8.8.8.8', connectTimeout: 1000, retry: false});
var start = new Date().getTime();
client.get({path: '/ping'}, function (err, req, res, body) {
console.log('Finished in: ' + (new Date().getTime() - start));
process.exit();
});

Expected: 'Finished in 1000'
Actual: 'Finished in 76345'

The problem here is that socket is mistakenly treated as 'connected' instead of 'connecting'. _connecting property is actually inside 'socket' property of the socket and not in it's root.