postwait / node-amqp

[UNMAINTAINED] node-amqp is an AMQP client for nodejs
MIT License
1.69k stars 358 forks source link

queue.unbind() blows up when the passed exchange name is not known to the client #445

Open gisode opened 7 years ago

gisode commented 7 years ago

I have a piece of software that uses queue.bind() to bind a queue to an exchange with a random name. When I receive a message from that queue, I want to unbind the queue from the exchange. For that purpose the message contains the exchange name, which I use with queue.unbind(). This works great.

The problem arises when my software is restarted after the bind but before the unbind because then queue.unbind() blows up in my face. Source code of this function shows that there is no guard against this._bindings[exchangeName] being undefined.

I have a fix and will post a PR. In the meantime, a workaround is to make the exchange known by calling connection.exchange() before calling queue.unbind().

I'm using amqp-0.2.6 and node-6.9.1.