tim-kos/node-retry

.wrap() calls last specified function for all calls

atamon opened this issue · 4 comments

Hi,

I found that the .wrap() function acts oddly when being called as follows:

var obj = {
  fn1: function () { ... },
  fn2: function () { ... },
};

retry.wrap(obj, { nRetries: 3, randomize: true }, ['fn1', 'fn2']);

Both obj.fn1() and obj.fn2() will now call the same original function due to this line https://github.com/tim-kos/node-retry/blob/master/lib/retry.js#L76. The variable original will be hoisted to the top of the function declaration of wrap.

I'm going to solve my specific use-case by calling wrap twice, once per function instead. But if you'd like to, I could try to get back with a PR for solving this.

Yes, I'd be happy to accept a PR for this.

Nice find!

Hey @atamon

Would you still like to send a PR for this?

Hi @tim-kos! Of course, it slipped my mind back a year ago. Please see #52 for what I had in mind back then.

Fixed in #52 (review) Thank you!