Fix ECONNRESET error emitted after failed connect (#1230)

On Windows, after a connect attempt has failed, an error event with
ECONNRESET is emitted after the real connect error is propagated to the
connect callback, because the connection is not in ending state
(connection._ending) where ECONNRESET is ignored. This change ends the
connection when connect has failed.

This fixes #746.
This commit is contained in:
Magnus Hiie 2017-03-20 19:01:41 +02:00 committed by Brian C
parent 549404e21e
commit 197f86f90d

View File

@ -182,6 +182,7 @@ Client.prototype.connect = function(callback) {
if(!callback) {
return self.emit('error', error);
}
con.end(); // make sure ECONNRESET errors don't cause error events
callback(error);
callback = null;
});