Client errors are not retried when 500 is not included in retryStatusCodes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 195
- PR merge metrics
- No merged PRs in 30d
Description
Environment
ofetch 1.4.1
Reproduction
https://stackblitz.com/edit/vitejs-vite-i5wbs4ho?file=src%2Fmain.js
Describe the bug
When retryStatusCodes does not includes error code 500, ofetch no longer retries client errors.
Additional context
Error code 500 is the generic error code for any unhandled error in the backend.
On POST requests some data may already have created when the error happens,
On other requests it usually output some error logs on the backend side, so retrying will just mess the backend logs.
So to my opinion this is not a good idea to retry backend 500 errors automatically.
I would like to be able to retry only Reverse Proxy related errors (Bad Gateway, Service unavailable, ...) and client errors.
Currently, if I exclude error 500, it no longer retries client errors which is not expected.
This behavior is due to the following line:
https://github.com/unjs/ofetch/blob/main/src/fetch.ts#L62C1-L62C81
When response is empty, the response code is resolved as 500.
Logs
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/fetch.ts around line 62 and reproduce the behavior with the linked StackBlitz example. Verify that omitting status 500 from retryStatusCodes still allows client errors to be retried while 500 responses are not retried.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100