Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs improvement] explanation of how retry is working #263

Closed
1 task done
picunada opened this issue Aug 16, 2023 · 1 comment
Closed
1 task done

[Docs improvement] explanation of how retry is working #263

picunada opened this issue Aug 16, 2023 · 1 comment

Comments

@picunada
Copy link
Contributor

picunada commented Aug 16, 2023

Describe the Improvement

Hello,

after reading the documentation, I wanted to use retry in my requests. I was confused as to why retries was not happening.

Digging around, I've found this issue #109 which states that retries occurs if response code is included in list of retryStatusCodes.

I suggest adding an explanation in which cases retries occurs to avoid confusion.

Code block

// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
const retryStatusCodes = new Set([
  408, // Request Timeout
  409, // Conflict
  425, // Too Early
  429, // Too Many Requests
  500, // Internal Server Error
  502, // Bad Gateway
  503, // Service Unavailable
  504 //  Gateway Timeout
])

...

if (retries > 0 && retryStatusCodes.has(responseCode)) {
    return $fetchRaw(ctx.request, {
         ...ctx.options,
         retry: retries - 1
     })
}

Additional information

  • Would you be willing to help implement this feature?
picunada added a commit to picunada/ofetch that referenced this issue Aug 16, 2023
Added explanation in which cases retry occur.
Issue unjs#263 .
@pi0
Copy link
Member

pi0 commented Aug 16, 2023

Thanks for PR!

@pi0 pi0 closed this as completed Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants