Skip to content

error filter for retry and retryable #1256

@bojand

Description

@bojand

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions