title: Swift. Combine. Is there any way to call a publisher block more than once when retry?
body: <p>I want to make a network request more than one time when some error occurs using retry() from Swift/Combine. The block inside the publisher is called once only which means one only one request is made for a real app when error happens. My code is:</p>
  
  <pre class="lang-swift prettyprint-override"><code>import UIKit
  import Combine
  import PlaygroundSupport
  
  enum TestFailureCondition: Error {
      case invalidServerResponse
  }
  
  var backgroundQueue: DispatchQueue = DispatchQueue(label: "backgroundQueue")
  
  var failPublisher: AnyPublisher&lt;(Data, URLResponse), Error&gt; {
      Future&lt;(Data, URLResponse), Error&gt; { promise in
          print("Attempt to call")
          backgroundQueue.asyncAfter(deadline: .now() + Double.random(in: 1..&lt;3)) {
              promise(.failure(TestFailureCondition.invalidServerResponse))
          }
      }
      .eraseToAnyPublisher()
  }
  
  let cancellable = failPublisher
  .print("(1)&gt;")
  .retry(3)
  .print("(2)&gt;")
  .sink(receiveCompletion: { fini in
      print(" ** .sink() received the completion:", String(describing: fini))
  
  
      PlaygroundPage.current.finishExecution()
  }, receiveValue: { stringValue in
      print(" ** .sink() received \(stringValue)")
  })
  
  PlaygroundPage.current.needsIndefiniteExecution = true
  </code></pre>
  
  <p>I expect that <code>backgroundQueue.asyncAfter(deadline)</code> is called three time before some error happens. Does anyone know why?</p>