-
It could be that my ky fetch isn't configured correctly but I haven't seen retry attempts after timeouts. Is this something that is supported with ky/ky-universal? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
actually it looks like the calculateRetryDelay, we are excluding timeouts: is there a reason in particular why timeouts are excluded from retries? |
Beta Was this translation helpful? Give feedback.
-
Why? You can just set a longer timeout instead. |
Beta Was this translation helpful? Give feedback.
-
Timeout means to give up on the request, e.g. to avoid having users stare at a loading spinner forever. I can see how this could be a little confusing since if the request seems to be hanging, then one could argue it is in a failure state and we retry other failure states. However, the difference is that in the other cases we have a definitive result, whereas a timeout is more like a judgement or prediction without any contextual information. Retrying a request just because it's taking a long time is probably not advisable in most cases. The server might be overloaded and retries would exacerbate the problem. The internet connection might be slow and retries would probably not improve the overall throughput (given that the request would be restarted from scratch). What I would recommend is setting a relatively long timeout like 30 seconds (or even disable timeouts altogether) and rely on the browser to report failures which Ky will retry. If you're still experiencing hanging requests, it would be good to investigate a little further to determine what is causing it. |
Beta Was this translation helpful? Give feedback.
-
that makes sense to me. appreciate the explanation. i'll close this inquiry! |
Beta Was this translation helpful? Give feedback.
-
Hi, I need to retry after a timeout, is there any built-in method? |
Beta Was this translation helpful? Give feedback.
Timeout means to give up on the request, e.g. to avoid having users stare at a loading spinner forever. I can see how this could be a little confusing since if the request seems to be hanging, then one could argue it is in a failure state and we retry other failure states. However, the difference is that in the other cases we have a definitive result, whereas a timeout is more like a judgement or prediction without any contextual information. Retrying a request just because it's taking a long time is probably not advisable in most cases. The server might be overloaded and retries would exacerbate the problem. The internet connection might be slow and retries would probably not improve the…