http: use socket.once, not socket.on
authorBen Noordhuis <info@bnoordhuis.nl>
Fri, 1 Mar 2013 12:01:53 +0000 (13:01 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Fri, 1 Mar 2013 12:11:40 +0000 (13:11 +0100)
Register the 'close' event listener with .once(), not .on().

It doesn't matter in the grand scheme of things because the listener
doesn't keep references to any heavy-weight objects but using .once()
for a oneshot listener is something of a best practice.

lib/http.js

index 212b8be..8fddd39 100644 (file)
@@ -515,7 +515,7 @@ OutgoingMessage.prototype._writeRaw = function(data, encoding) {
       var timer = setTimeout(function() {
         socket.emit('close');
       });
-      socket.on('close', function() {
+      socket.once('close', function() {
         clearTimeout(timer);
       });
     }