Open aaronatbissell opened 1 year ago
Even if you make it something simple like this, it still only waits for 300ms
this.client = contentstack.client({
retryLimit: 4,
timeout: 60 * this.SEC_TO_MS,
retryDelayOptions: {
customBackoff: (retryCount, _error) => 1000 * retryCount,
},
});
thanks for raising the issue, We will look into it @aaronatbissell.
@aaronatbissell The main difference between the two code snippets is how the customBackoff function calculates the retry delay.
this.client = contentstack.client({
retryLimit: 4,
timeout: 60 * this.SEC_TO_MS,
/**
* Exponential backoff logic:
* retry | total elapsed time since original request (sec)
* 0 | 0.000
* 1 | 0.250
* 2 | 0.750
* 3 | 1.750
* 4 | 3.750
*/
retryDelayOptions: {
customBackoff: (retryCount, _error) =>
0.25 * Math.pow(2, retryCount) * this.SEC_TO_MS,
},
});
0.25 * Math.pow(2, retryCount) * this.SEC_TO_MS
.0.25 * Math.pow(2, 0) * 1000 = 250 ms
0.25 * Math.pow(2, 1) * 1000 = 500 ms
0.25 * Math.pow(2, 2) * 1000 = 1000 ms
0.25 * Math.pow(2, 3) * 1000 = 2000 ms
0.25 * Math.pow(2, 4) * 1000 = 4000 ms
this.client = contentstack.client({
retryLimit: 4,
timeout: 60 * this.SEC_TO_MS,
retryDelayOptions: {
customBackoff: (retryCount, _error) => 1000 * retryCount,
},
});
1000 * retryCount
.1000 * 0 = 0 ms
1000 * 1 = 1000 ms
1000 * 2 = 2000 ms
1000 * 3 = 3000 ms
1000 * 4 = 4000 ms
First Snippet:
Second Snippet:
Depending on your needs, you might prefer one method over the other. Exponential backoff is generally more effective at handling temporary server overloads, while linear backoff is simpler and may be suitable for other types of retries.
I understand the difference between exponential and linear back-off.
The problem was that no matter what you put as the customBackoff
function, it will always wait for 300ms (and the statement that gets printed to the screen always says "waiting 300ms")
~Note: this issue is over a year old and I haven't tested to see if this is STILL an issue~
Just tested - this still appears to be an issue with v1.17.0
Here's a repo that reproduces the issue: https://github.com/aaronatbissell/contentstack-management-javascript-issue-55
Hi @aaronatbissell we will be looking into the issue as earliest as possible and we have taken it in the upcoming sprint. We will post the reply once fixed cc: @harshithad0703 @sunil-lakshman @netrajpatel @shafeeqd959
The
customBackoff
function that can be passed toretryDelayOptions
doesn't appear to change the retry delay at all. The delay still appears to be 300ms no matter what. The message printed on screen also indicates 300ms no matter what.Here's the client we are using: