Skip to content

Commit af249fa

Browse files
committed
net: wrap connect in nextTick
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 <[email protected]> Reviewed-by: Trevor Norris <[email protected]>
1 parent 9180140 commit af249fa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/net.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,9 @@ function lookupAndConnect(self, options) {
925925
// TODO(evanlucas) should we hot path this for localhost?
926926
var addressType = exports.isIP(host);
927927
if (addressType) {
928-
connect(self, host, port, addressType, localAddress, localPort);
928+
process.nextTick(function() {
929+
connect(self, host, port, addressType, localAddress, localPort);
930+
});
929931
return;
930932
}
931933

0 commit comments

Comments
 (0)