ofetch: onRequestError called 3 times (with retry), is this expected? #77
Replies: 1 comment
-
|
I just found out i can get |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Environment
1.4.1Code
Description
With the configuration above:
retryis set to2andretryDelayis set to500ms.onResponseErrorworks as expected: it is only called after the last retry fails (i.e., after 3 total attempts).onRequestError, it gets called 3 times, once for each failed attempt.Objective
My goal is to show a toast error notification only once, after the final retry fails, for network-related issues or other request errors.
Right now, because
onRequestErroris called on each retry, the toast shows multiple times which is not the desired UX.Question
Is this the intended behavior of
onRequestError?And is there a way to make it behave like
onResponseError, so it only gets called once after all retries fail?Or is there any recommended workaround to achieve this behavior?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions