unjs / ofetch

😱 A better fetch API. Works on node, browser and workers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onRequestError should called only once when retry?

kaokei opened this issue · comments

Describe the feature

The context is that I have disabled the Wi-Fi on the computer, which will definitely trigger the onRequestError hook. Currently, for GET requests, there is a default retry of 1 time, and each retry will execute onRequestError. Because I display a pop-up window with the error message in onRequestError, there are two pop-up windows for each request.

I understand that the retry mechanism should be transparent to the business, and the business does not care how many times it has been retried. The business only cares whether the API ultimately succeeds or fails. Therefore, I suggest that exception hooks such as onRequestError and onResponseError should not be executed repeatedly during retries.

Of course, this is just my personal understanding. If there is any misunderstanding on my part, please feel free to disregard this request.

Additional information

  • Would you be willing to help implement this feature?