Skip to content

raiseError causes writeOutputStream to hang #2931

@armanbilge

Description

@armanbilge

H/t to @bpholt for the original minimization in https://github.com/Dwolla/fs2-hang-repro

//> using scala "3.1.3"
//> using lib "co.fs2::fs2-io::3.2.8"

package repro

import cats.effect._
import cats.syntax.all._
import fs2._
import fs2.io.{readOutputStream, writeOutputStream}

object Bug extends IOApp.Simple {
   
  override def run: IO[Unit] = {
    val s = Stream
      .emit[IO, Byte](0)
      .repeat
      .take(3)
      .through { in =>
        readOutputStream(1) { out =>
          in
            .through(writeOutputStream(IO.pure(out)))
            .compile
            .drain
        }
      }

    // remove the raiseError and it completes normally
    (s *> Stream.raiseError[IO](new RuntimeException("boom"))).compile.drain
  }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions