Skip to content

Commit

Permalink
Fix amqp reconnect function timeout handling (#185)
Browse files Browse the repository at this point in the history
* use a dedicated timeout ID variable to manage and clear the reconnection timeout
* this prevents stacked reconnection attempts by ensuring the timeout is cleared on successful reconnect
  • Loading branch information
gplechuck authored Dec 14, 2023
1 parent b7d7d82 commit cdfdb48
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/outputs/output_amqp.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ OutputAmqp.prototype.publish = function(message,options){

OutputAmqp.prototype.reconnect = function() {
let self = this;
setTimeout(()=>{
self.reconnectTimeoutId = setTimeout(() => {
self.connect().then(() => {
clearTimeout(self.reconnect);
clearTimeout(self.reconnectTimeoutId);
}).catch((err) => console.error(err));
},self.retry_delay);
}, self.retry_delay);
};

OutputAmqp.prototype.connect = function(){
Expand Down

0 comments on commit cdfdb48

Please sign in to comment.