-
Notifications
You must be signed in to change notification settings - Fork 146
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.