Skip to content

Commit

Permalink
net: wrap connect in nextTick
Browse files Browse the repository at this point in the history
Fixes an edge case regression introduced in
1bef717.

With the lookup being skipped, an error could be emitted before an
error listener has been added.

An example of this was presented by changing the server’s IP address
and then immediately making a request to the old address.

Related: nodejs#1823
PR-URL: nodejs#2054
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-by: Trevor Norris <[email protected]>
  • Loading branch information
evanlucas authored and mscdex committed Jul 9, 2015
1 parent 3a80d9c commit 8c43ff2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,9 @@ function lookupAndConnect(self, options) {
// TODO(evanlucas) should we hot path this for localhost?
var addressType = exports.isIP(host);
if (addressType) {
connect(self, host, port, addressType, localAddress, localPort);
process.nextTick(function() {
connect(self, host, port, addressType, localAddress, localPort);
});
return;
}

Expand Down

0 comments on commit 8c43ff2

Please sign in to comment.