Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixes memory leak for confirmed messages #142

Merged
merged 1 commit into from

2 participants

@ZeissS

I played around with confirmation of messages published to an exchange. Since every message subscribes to error on the exchange, the maxListener limit is hit almost immediately.

This fix removes the error-callback for acknowledged messages from the exchange. One does still need to call setMaxListeners() on the exchange to match the number of expected unconfirmed messages.

@postwait postwait merged commit 9fde5b0 into postwait:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 21, 2012
  1. @ZeissS
This page is out of date. Refresh to see the latest.
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);
}
}
Something went wrong with that request. Please try again.