# Source.queue bug?

**URL:** <https://discuss.akka.io/t/source-queue-bug/8535>\
**Category:** Akka Streams & Alpakka\
**Tags:** akka, akka-typed, scala, streams\
**Created:** [July 21, 2021, 9:35am UTC](https://discuss.akka.io/t/source-queue-bug/8535 "2021-07-21T09:35:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dounine](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/dounine/32/2473_2.png) [@dounine](https://discuss.akka.io/u/dounine)\
**Post date:** [July 21, 2021, 9:35am UTC](https://discuss.akka.io/t/source-queue-bug/8535/1 "2021-07-21T09:35:47Z")

</div>

My code is below

```auto
val (chromeQueue, chromeSources) =
  Source
    .queue[Int](1, OverflowStrategy.dropNew)
    .preMaterialize()

val (orderQueue, orderSources) =
  Source
    .queue[String](1, OverflowStrategy.dropNew)
    .preMaterialize()

orderSources
  .zip(chromeSources)
  .to(Sink.ignore)
  .run()

Source(Seq("a", "b", "c", "d"))
  .mapAsync(1) { i =>
    orderQueue.offer(i).map {
      case result: QueueCompletionResult => println("completion")
      case QueueOfferResult.Enqueued => println("enqueued")
      case QueueOfferResult.Dropped => println("dropped")
    }
  }
  .runWith(Sink.ignore)

```

I Expected code results

```auto
enqueued
dropped
dropped
dropped

```

But actual results

```auto
enqueued
enqueued
enqueued
enqueued

```

akka version: 2.6.15

---

<div class="post-metadata">

**Author:** ![raboof](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/raboof/32/2913_2.png) [@raboof](https://discuss.akka.io/u/raboof)\
**Post date:** [July 21, 2021, 10:04am UTC](https://discuss.akka.io/t/source-queue-bug/8535/2 "2021-07-21T10:04:22Z")

</div>

So, you expected this to log `dropped` because the `zip` backpressures when it hasn’t received objects on `chromeQueue` yet.

One cause for this is the internal buffers Akka Streams can insert between stages: you can read more about those at [Buffers and working with rate • Akka Documentation](https://doc.akka.io/docs/akka/2.6.15/stream/stream-rate.html). When you add the following configuration (just for illustration, I wouldn’t recommend doing this in production):

```auto
akka.stream.materializer.initial-input-buffer-size = 1
akka.stream.materializer.max-input-buffer-size = 1

```

… and add some more elements to the `Seq`, you get output like:

```auto
enqueued
enqueued
enqueued
enqueued
dropped
dropped
dropped
dropped
dropped
dropped

```

There still seems to be some buffering going on, though I’m not entirely sure where that is coming from - that would need some further investigation. In any case: the backpressure in Akka Streams is mainly intended to avoid overwhelming a slow downstream, but may still add buffers for throughput. Many stages won’t really do ‘per-element’ flow control, but batch things up.
