From 6326b04b071c240955200bd92a080483d0397344 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 19 Sep 2011 13:41:42 -0700 Subject: [PATCH] Fix test-regress-GH-819 Problem was exposed in 12798c6. --- lib/net_uv.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/net_uv.js b/lib/net_uv.js index b53b3ba89dc..0fcdce9fe97 100644 --- a/lib/net_uv.js +++ b/lib/net_uv.js @@ -483,6 +483,11 @@ Socket.prototype.connect = function(port /* [host], [cb] */) { } else if (typeof host == 'string') { debug("connect: find host " + host); require('dns').lookup(host, function(err, ip, addressType) { + // It's possible we were destroyed while looking this up. + // XXX it would be great if we could cancel the promise returned by + // the look up. + if (!self._connecting) return; + if (err) { // net.createConnection() creates a net.Socket object and // immediately calls net.Socket.connect() on it (that's us).