Permalink
Browse files

Fixes memory leak for confirmed messages

  • Loading branch information...
1 parent faee8d6 commit 9fde5b0951a58ec82d5539a2ee8095c8acbce418 @zeisss committed Oct 21, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 amqp.js
View
8 amqp.js
@@ -2186,9 +2186,11 @@ Exchange.prototype.publish = function (routingKey, data, options, callback) {
self._unAcked[self._sequence] = task
self._sequence++
- if(callback != null){
- task.once('ack', function(){task.removeAllListeners();callback(false)});
- this.once('error', function(){task.removeAllListeners();callback(true)});
+ if(callback != null){
+ var errorCallback = function(){task.removeAllListeners();callback(true)};
+ var exchange = this;
+ task.once('ack', function(){exchange.removeListener('error', errorCallback); task.removeAllListeners();callback(false)});
+ this.once('error', errorCallback);
}
}

0 comments on commit 9fde5b0

Please sign in to comment.