storyblok-js-client: Retry query functionality does not work

Before axios was removed, i.e. before version 5.0.0, the retry request functionality worked and you could see messages in the console about it console.log(`Hit rate limit. Retrying in ${retries} seconds.`) At the moment this functionality is broken and retries are not performed.


Expected Behavior

Data requests are retried in case of an error.

Current Behavior

Request crashes without retry

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 24 (3 by maintainers)

Most upvoted comments

Since removing Axios HTTP responses with status code will no longer throw an exception. That is why the

if (res.status !== 200) {
   return reject(res)
}

section is hit. In the Axios case this would have never been hit as the request would have thrown an exception.

One way of fixing this is to do the 429 check before the 200 check as follows:

if (res.status === 429) {
  retries = retries ? retries + 1 : 0

  if (retries < this.maxRetries) {
    console.log(`Hit rate limit. Retrying in ${retries} seconds.`)
    await this.helpers.delay(1000 * retries)
    return this.cacheResponse(url, params, retries)
	    .then(resolve)
	    .catch(reject)
    }
}
if (res.status !== 200) {
   return reject(res)
}

@berenar Not yet. We are looking this one with our back end team to figure out what is happening here. We’ll keep you informed through this thread.

@serGlazkov We’ll closing a pull request soon to solve this one. I’ll keep you posted here.

@serGlazkov Please try out this new version to check if the issue was solved.

@serGlazkov Thanks for the heads up. We’'l check this one.