Skip to content

Ability to change retry() params from the task? #1001

@eexit

Description

@eexit

Hello,

I would like to know if it'd be possible to be able to update the times argument of the retry() from the task?
For instance, I would like to be able to increase the interval value as the attempt count increases or trim down the attempt count to 0 when a particular error occurred (in order to avoid unnecessary doomed attempts).

Example:

var opts = {
    times: 3,
    interval: 500
};

async.retry(opts, function (callback) {
    someCall(function(err) {
        if (err) {
            switch (err.code) {
                case 'Code1':
                    opts.interval += 500; // Increases the interval for next attempt
                    return callback(err);
                case 'Code2':
                    opts.times = 0; // Avoid other attempts
                    return callback(err);
                default:
                    return callback(err);
            }
        }

        callback();
    });
}, function (err) {
    // Some code
});

Any idea or workaround?

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions