Skip to content

Stream hangs non-deterministically when using mapAsync #1297

@vlovgr

Description

@vlovgr

The following program:

import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import fs2.Stream

object Main extends IOApp {
  override def run(args: List[String]): IO[ExitCode] = {
    val stream =
      Stream
        .iterate(0)(_ + 1)
        .covary[IO]
        .mapAsync(25) { n =>
          if (n > 100) IO.raiseError(new RuntimeException)
          else IO(println(n))
        }

    stream.compile.drain.as(ExitCode.Success)
  }
}

when run somtimes hangs (never completes) indefinitely. It might take several runs/attempts for the hang to occur, but I'm always able to eventually trigger it locally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions