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

Doc example improvement: 400 should not retry #176

Open
dmudro opened this issue Mar 12, 2023 · 3 comments
Open

Doc example improvement: 400 should not retry #176

dmudro opened this issue Mar 12, 2023 · 3 comments

Comments

@dmudro
Copy link

dmudro commented Mar 12, 2023

been using wretch for some time, nice little lib indeed.

it might be worth tweaking the retry example or defaults to ignore certain http responses that should almost never retry.

we had a case with Zoom API recently where initial POST resulted in 400 Bad Request which retried a few times and subsequently causing 429 Too Many Requests. things like 400 bad request is almost always client's fault!

maybe adding a simple check in the doc or adding a new option / default?

...
retry({
    ...
    // didn't try this yet:
    until: (response, error) => response && (response.ok || ![408, 413, 500, 502, 503, 504].includes(response.status)),
    // or a new option?
    // retryOnAnyResponse: false,
    retryOnNetworkError: false,
    resolveWithLatestResponse: false
  })
...
@elbywan
Copy link
Owner

elbywan commented Mar 12, 2023

Hey @dmudro 👋

been using wretch for some time, nice little lib indeed.

Thanks!

it might be worth tweaking the retry example or defaults to ignore certain http responses that should almost never retry.

You are absolutely right, this should be the default behaviour to skip retrying on 4xx errors. But until wretch v3.x.x is released (to avoid a breaking change) I just pushed a commit to clarify it in the readme and typescript doc.

@EliottG-Bam
Copy link

Hey, I tried digging in the lib but I'm not sure I understand correctly. The retry mechanism happens only when using the retry middleware right? If I use wretch without anything else, I should have no retry when I'm calling my function?

@elbywan
Copy link
Owner

elbywan commented Jun 29, 2024

The retry mechanism happens only when using the retry middleware right?

Hey, yes it is only when adding the retry middleware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants