fetchp icon indicating copy to clipboard operation
fetchp copied to clipboard

Request Retries

Open fdemir opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. The fetchp does not allow users to retry failed requests, which can cause problems with data transfers. Adding a request retry feature would make transfers more reliable and successful.

Describe the solution you'd like The retry property in the FetchpRequestInit interface allows users to specify whether or not to retry failed requests, and how many times to retry them. It can be set to a boolean value, a number, or a custom function that determines whether or not to retry a request based on the error that occurred.

  • If retry is set to true, the fetchp will automatically retry failed requests once.
  • If retry is set to a number, the fetchp will automatically retry failed requests that number of times.
  • If retry is set to a custom function, the fetchp will pass the error that occurred to the function, and will only retry the request if the function returns true.

Additional context The retryDelay function calculates the time to wait before retrying based on the attemptIndex, which starts at 0 for the first attempt. It can be used to increase the delay with each retry attempt to prevent overwhelming the server.

fdemir avatar Dec 20 '22 22:12 fdemir