From 5d97d727536b33dfca6fc582033aed64f921f65f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 12 Jul 2012 16:56:42 +0200 Subject: [PATCH] net: fix bogus errno reporting _listen2() emits the error on the next tick. The errno value may have changed by then. --- lib/net.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/net.js b/lib/net.js index d6a01aa837d..f129c0cce7b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -911,10 +911,11 @@ Server.prototype._listen2 = function(address, port, addressType, backlog, fd) { r = self._handle.listen(backlog || 511); if (r) { + var ex = errnoException(errno, 'listen'); self._handle.close(); self._handle = null; process.nextTick(function() { - self.emit('error', errnoException(errno, 'listen')); + self.emit('error', ex); }); return; }