Open sagnik-sanyal opened 3 months ago
Hello @sagnik-sanyal thank you for submitting this issue. We will look into this and get back to you!
Hi @tyllark any update on this issue ?
Hello @sagnik-sanyal - Currently you would need to create a new operation.
Alternatively, you may be able to provide your own http client to the API plugin and use an http client that retries the request. I would need to look into this a bit more to see if this would work.
Let me know if you have other questions.
@Jordan-Nelson i would like to have an example of the second implementation that you mentioned, for retrying and cancelling the request
@sagnik-sanyal - Here is an example of using a custom http client. This is a fairly simple example of adding a header to each request. I would need to confirm if this can be used to retry requests.
Thanks @Jordan-Nelson for providing valuable insights, yeah I will try this to achieve retrying the requests, but can this be cancelled or how to access whether it has been cancelled from the custom client ( let's say the user left the screen while the request was retrying so there's no need to perform the request ) ?
RestOperation should still be cancellable when using a custom client. RestOperation
has a cancel()
method.
Thanks for helping us although we would love to have a utility or a resuable extension to retry the api calls @Jordan-Nelson
@sagnik-sanyal I am going to label this as a feature request for the ability to retry the request.
Description
I have an important requirement to be able to retry the http request based upon some condition for specified number of attempts for which i am using the extension below , also note that .retry is a custom extension on future to retry the future. So here if the exception is HttpStatusException with status code 500 or some other code i need to retry the request.
But i guess that as the package internally relies on CancellableCompleter, if the first request fails and perform retry i get an error below on the second request ->
Do i need to create a new RestOperation object everytime a new request is sent or am i missing something ? This function is going to be used all across the application so that the retry gets cancelled if request was cancelled and also perform retry if the request fails and the operation is still active.
Categories
Steps to Reproduce
N/A
Screenshots
No response
Platforms
Flutter Version
3.22.1
Amplify Flutter Version
2.1.0
Deployment Method
Amplify CLI
Schema
No response