question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to change retry() params from the task?

See original GitHub issue

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,

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
aearlycommented, Jun 9, 2016

I think the behavior added in #1161 should be good enough for now.

0reactions
aearlycommented, May 12, 2016

Hmmn, perhaps we could make the retry opts more polymorphic – if you pass an array for the interval, it uses those numbers for each delay interval in sequence.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP retry change url's parameter - javascript - Stack Overflow
this.myRequest() .pipe(this.http_retry()) .subscribe(resData => { ...
Read more >
Retry pipeline - provide variables, their values (hidden) and ...
You can retry a pipeline, quickly changing on the variables necessary, without having to re-run the entire pipeline from scratch and entering in ......
Read more >
Error handling in Step Functions - AWS Documentation
An attempt to replace a field, within a state's Parameters field, ... Task and Parallel states can have a field named Retry ,...
Read more >
Retry pattern - Azure Architecture Center | Microsoft Learn
Implement retry logic only where the full context of a failing operation is understood. For example, if a task that contains a retry...
Read more >
Retrying event-driven functions - Google Cloud
If you want to retry the function when an error occurs, you can change the default retry policy by setting the "retry on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found