Created
July 22, 2010 04:20
-
-
Save ConradIrwin/485563 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/net.js b/lib/net.js | |
index 0bbbdf0..0bd4c7a 100644 | |
--- a/lib/net.js | |
+++ b/lib/net.js | |
@@ -896,6 +896,10 @@ Stream.prototype.connect = function () { | |
dns.lookup(arguments[1], function (err, ip, addressType) { | |
if (err) { | |
self.emit('error', err); | |
+ // If the stream is destroyed during the DNS lookup, by an extravagent timeout for example | |
+ // then continuing is futile. | |
+ } else if (!self._readWatcher) { | |
+ self.emit('error', "Stream already destroyed") | |
} else { | |
self.type = addressType == 4 ? 'tcp4' : 'tcp6'; | |
self.fd = socket(self.type); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var common = require("../common"); | |
var assert = common.assert | |
var net = require('net'); | |
var socket = net.createConnection(80, 'localhost'); | |
process.nextTick(function () { | |
socket.destroy(); | |
}); | |
socket.on('error', function (err) { | |
assert.equal('Stream already destroyed', err); | |
}); | |
socket.on('connect', function (err) { | |
assert.fail(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment