title: How to retry URL requests indefinitely until success with Alamofire 5?
body: <p>Is there any recommendation on using Alamofire's RequestRetrier to keep retrying a request until it succeeds?</p>
  <p>The issue I'm running into is every time a retry happens it increases the memory of the app.  I have a scenario that a user might make a request offline and it should eventually succeed when they regain connection.</p>
  <p>Is it not good practice to continually retry a request?  Should I use a Timer instead to to recreate the network call if it fails a few times?  Should I use some other mechanism that waits for network activity and then sends up a queue of requests (any suggestions on what that would be would be appreciated!)?</p>
  <p>Here is an example to see the memory explode.  You just need to put your iPhone in airplane mode (so there is no connection) and the memory will keep going up rapidly since the call will happen a lot in this case.</p>
  <pre><code>import UIKit
  import Alamofire    
  class ViewController: UIViewController {
      let session = Session(configuration: .default)    
      override func viewDidLoad() {
          super.viewDidLoad()
          sendRequest()
      }
      func sendRequest() {
          session.request(&quot;https://www.google.com&quot;, method: .get, interceptor: RetryHandler())
              .responseData { (responseData) in
              switch responseData.result {
              case .success(let data):
                  print(String(data: data, encoding: .utf8) ?? &quot;nope&quot;)
              case .failure(let error):
                  print(error.localizedDescription)
              }
          }
      }
  }
  </code></pre>
  <hr />
  <pre><code>class RetryHandler: RequestInterceptor {
      func retry(_ request: Request, for session: Session, dueTo error: Error, completion: @escaping (RetryResult) -&gt; Void) {
          // keep retrying on failure
          completion(.retry)
      }
  }(
  </code></pre>