maxRetries when handling rare limit

On my App, I am getting error 429 when calling too many api at the same time. I am handling this error according to the documentation described

// Defaults may vary based on the app use case and APIs being called.
let maxRetries = 4; // Should be 0 to disable (e.g. API is not idempotent)
let lastRetryDelayMillis = 5000;
let maxRetryDelayMillis = 30000;
let jitterMultiplierRange = [0.7, 1.3];

// Re-entrant logic to send a request and process the response...
let response = await fetch(...);
if (response is OK) {
} else {
  let retryDelayMillis = -1;
  if (hasHeader('Retry-After') {    
    retryDelayMillis = 1000 * headerValue('Retry-After');
  } else if (statusCode == 429) {
    retryDelayMillis = min(2 * lastRetryDelayMillis, maxRetryDelayMillis);
  if (retryDelayMillis > 0 && retryCount < maxRetries) {
    retryDelayMillis += retryDelayMillis * randomInRange(jitterMultiplierRange);
  } else {

. However, I have a question: What is the maximum maxRetries here, or can we handle it and wait until the api call is successful? Because the api error 429 will block my entire running process

Hello @HungTran,

Yes, technically, you can increase the maximum retries here and handle the rate-limiting error until the API call is successful. However, I would recommend using a good backoff strategy in order to not flood the system with requests and overwhelm it e.g., exponential backoff with jitter.