title: What does timeout operator measure in Reactor and why it doesn't work in some cases?
body: <p>Recently, a reactive piece of code results in <code>timeout</code>, it involves redis operation, like this:</p>
  <pre><code>redisOps.entries(key).map(...).map(...).switchIfEmpty().timeout();
  </code></pre>
  <p>In order to identify if timeout happens in redis query, I think <code>timeout</code> should be located after <code>entries</code>, in this way, <code>map</code> consumed time would not be monitored by <code>timeout</code>. So I made a guess, and wrote demo.</p>
  <ol>
  <li>does timeout monitor data emission elapsed time until it, and data operations after it is not counted? For example, in the following code snippet, only time consumption in <code>a</code> and <code>b</code> are monitored by <code>timeout</code>, not including <code>c</code> or <code>d</code>.</li>
  </ol>
  <pre><code>   Mono mono = foo();
     mono.a().b().timeout().c().d();
  </code></pre>
  <ol start="2">
  <li>Why in the following code, <code>timeout</code> does not work.</li>
  </ol>
  <pre><code>           Mono.just(&quot;good luck&quot;)
                  .map(s -&gt; {
                      try {
                          TimeUnit.SECONDS.sleep(1);
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
                      return &quot;timeout 1&quot;;
                  })
                  .map(s-&gt;{
                      try {
                          TimeUnit.SECONDS.sleep(1);
                      } catch (InterruptedException e) {
                          e.printStackTrace();
                      }
                      return &quot;timeout 2&quot;;
                  })
                  .timeout(Duration.ofSeconds(1))
                  .subscribe(System.out::println);
  </code></pre>
  <ol start="3">
  <li>compared with item 2, <code>timeout</code> in the following code works:</li>
  </ol>
  <pre><code>    public static void main(String[] args) {
          Mono.fromCallable(() -&gt; {
              log.info(&quot;begin 1&quot;);
              try {
                  TimeUnit.SECONDS.sleep(2);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              log.info(&quot;return 1&quot;);
              return &quot;good luck 1&quot;;
          })
          .timeout(Duration.ofMillis(1500l))
          .map((s) -&gt; {
              log.info(&quot;begin 2&quot;);
              try {
                  TimeUnit.SECONDS.sleep(1);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              log.info(&quot;return 2&quot;);
              return &quot;good luck 2&quot;;
          })
          .subscribe(System.out::println);
      }
  </code></pre>