Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error filter for retry and retryable #1256

Closed
bojand opened this issue Jul 28, 2016 · 2 comments
Closed

error filter for retry and retryable #1256

bojand opened this issue Jul 28, 2016 · 2 comments

Comments

@bojand
Copy link
Contributor

bojand commented Jul 28, 2016

Hello,

I did q quick search and didn't find similar issue... It would be useful to have retry and retryable accept an optional errorFilter sync function that will only allow the retry to continue if the function returns true. for example something like:

var retryOpts = {
  errorFilter: function (err) {
    if(err.code === 11) return true; // only retry for error code 11
    return false;
  }
};

async.retry(retryOpts, apiMethod, function(err, result) {
  // We know that we retried on error code 11, with other retry options being the defaults. 
  // if we got any other error we immediately bailed to here
  if(err) console.log(err); 
  console.log(result);
});

This could be done in backwards compatible manner. Opinions? Would this be something accepted? I could probably try and do a PR sometime next week if so.

Thanks,

Bojan

@megawac
Copy link
Collaborator

megawac commented Jul 28, 2016

I'd be open to this

@bojand bojand changed the title error filter for retry and retriable error filter for retry and retryable Jul 28, 2016
@aearly
Copy link
Collaborator

aearly commented Jul 30, 2016

Sounds good. When we added the interval function, we also wanted to add a way to handle errors differently, but couldn't think of a good way to expose that in the API. This seems like a good way to do it.

megawac added a commit that referenced this issue Aug 8, 2016
add filter option to retry() and retryable(). PR for #1256.
hargasinski pushed a commit to hargasinski/async that referenced this issue Oct 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants