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: #1823
PR-URL: #2054
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
evanlucas committed Jul 1, 2015
1 parent 9180140 commit af249fa
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 af249fa

Please sign in to comment.