diff options
author | Evan Lucas <evanlucas@me.com> | 2015-06-25 06:41:10 -0500 |
---|---|---|
committer | Evan Lucas <evanlucas@me.com> | 2015-06-30 23:16:26 -0500 |
commit | af249fa8a15bad8996187e73b480b30dcd881bad (patch) | |
tree | 843fbf2341249e3066789c1081b971ac1c44c0a4 | |
parent | 9180140231823f8a9cd6c6d7cf05d809d76299f2 (diff) | |
download | nodejs-af249fa8a15bad8996187e73b480b30dcd881bad.tar.gz nodejs-af249fa8a15bad8996187e73b480b30dcd881bad.tar.bz2 nodejs-af249fa8a15bad8996187e73b480b30dcd881bad.zip |
net: wrap connect in nextTick
Fixes an edge case regression introduced in
1bef71747678c19c7214048de5b9e3848889248d.
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: https://github.com/nodejs/io.js/pull/1823
PR-URL: https://github.com/nodejs/io.js/pull/2054
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
-rw-r--r-- | lib/net.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/net.js b/lib/net.js index 4c5e62b58..5a429a244 100644 --- a/lib/net.js +++ b/lib/net.js @@ -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; } |