Skip to content

Commit

Permalink
attach retry handler only once
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Jun 2, 2016
1 parent e37e0ea commit 46ddce1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,14 @@ module.exports = (options) => {

api.graceRequestHandlers = [];
api.attachRetryHandler = (fn) => {
if (_.isFunction(fn)) {
if (_.isFunction(fn) && api.graceRequestHandlers.indexOf(fn) < 0) {
api.graceRequestHandlers.push(fn);
} else {
api.graceRequestHandlers = api.graceRequestHandlers.concat(fn);
fn.forEach((f) => {
if (api.graceRequestHandlers.indexOf(f) < 0) {
api.graceRequestHandlers.push(f);
}
});
}
};

Expand Down

0 comments on commit 46ddce1

Please sign in to comment.