title: Should Flux.then and Mono.then behave differently in error case?
body: <p>I encountered a case where I have a nested Flux. I don't care about the individual results of the inner flux as it returns Unit (in Kotlin / Void in Java), but I want to know if the Flux aborted due to an error or not. I thought I could use the <code>then</code> function, as the doc states: <code>Error signal is replayed in the resulting Mono&lt;V&gt;</code></p>
  <p>My problem can be reduced to the minimum (Kotlin) unit test:</p>
  <pre class="lang-kotlin prettyprint-override"><code>    @Test
      fun fluxTest() {
          val flux = Flux.just(&quot;willFail&quot;, &quot;willSucceed&quot;)
              .flatMap { outer -&gt;
                  // In my real world example the inner flux is created via Flux.fromIterable from a property of the
                  // outer`-object
                  Flux.just(1)
                      .flatMap { inner -&gt;
                          // this simulates a Mono.fromSupplier that can throw exceptions
                          if (outer == &quot;willFail&quot;) Mono.error&lt;Unit&gt;(RuntimeException(&quot;bam&quot;))
                          else Mono.just(Unit)
                      }
                      // We don't care about the Flux as it returns Unit/Void
                      // All we want to know is, whether there was an error or not
                      .then(Mono.just(outer))
              }
              .onErrorContinue { error, item -&gt; println(&quot;$item =&gt; $error&quot;) }
              .collectList()
  
          StepVerifier.create(flux)
              .expectNextMatches { it.size == 1 }
              .verifyComplete()
      }
  </code></pre>
  <p>So we have 2 elements. In the inner Flux one of the elements will fail on processing and the other won't. I expect the error to propagate through the pipeline where it is catched and discarded in the <code>onErrorContinue</code>.
  Therefore I'd expect 1 element in the resulting list, but I get the original 2. I have no clue why.</p>
  <p>Now comes the fun part: In this particular test case, I can replace <code>Flux.just(1)</code> with <code>Mono.just(1)</code> (in my real world case this doesn't work ofc because the flux has more than 1 element) and suddenly my test passes:</p>
  <pre class="lang-kotlin prettyprint-override"><code>    @Test
      fun fluxTest() {
          val flux = Flux.just(&quot;willFail&quot;, &quot;willSucceed&quot;)
              .flatMap { outer -&gt;
                  // In my real world example the inner flux is created via Flux.fromIterable from a property of the
                  // outer`-object
                  Mono.just(1)
                      .flatMap { inner -&gt;
                          // this simulates a Mono.fromSupplier that can throw exceptions
                          if (outer == &quot;willFail&quot;) Mono.error&lt;Unit&gt;(RuntimeException(&quot;bam&quot;))
                          else Mono.just(Unit)
                      }
                      // We don't care about the Flux as it returns Unit/Void
                      // All we want to know is, whether there was an error or not
                      .then(Mono.just(outer))
              }
              .onErrorContinue { error, item -&gt; println(&quot;$item =&gt; $error&quot;) }
              .collectList()
  
          StepVerifier.create(flux)
              .expectNextMatches { it.size == 1 }
              .verifyComplete()
      }
  </code></pre>
  <p>So obviously there is a difference in <code>Mono.then(Mono&lt;T&gt;)</code> and in <code>Flux.then(Mono&lt;T&gt;)</code>, but it shouldn't since the Javadoc is the same right?</p>
  <p>Side note: Instead of <code>Flux.then(Mono.just(outer))</code> I also tried <code>Mono.defer</code> but that is not changing anything.</p>