Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS2 to ZStream: implicit errors are not propagated, stream hangs forever #702

Open
michalliss opened this issue Jan 16, 2025 · 0 comments
Open

Comments

@michalliss
Copy link

Hello,

I noticed a weird behaviour when converting FS2 stream to ZStream. It seems like errors reported using Stream.raiseError are propagated correctly to the ZStream, but errors reported implicitly make the stream hang forever. See example (uncomment one of the def run = ...:

//> using scala 3.3.4
//> using dep "dev.zio::zio::2.1.14"
//> using dep "dev.zio::zio-streams::2.1.14"
//> using dep "dev.zio::zio-interop-cats::23.1.0.3"
//> using dep "org.typelevel::cats-effect::3.5.7"
//> using dep "co.fs2::fs2-core::3.11.0"

import zio.*
import zio.stream.*
import zio.interop.catz.*
import zio.stream.interop.fs2z.*
import cats.implicits.*
import fs2.Stream

object Main extends ZIOAppDefault {
  def run = hangs
  // def run = works

  def hangs = {
    val stream =
      (Stream[Task, Int](1, 2, 3) ++ (throw new Throwable("error")))
        .toZStream()
    stream.runCollect
  }

  def works = {
    val stream = (Stream[Task, Int](1, 2, 3) ++ Stream.raiseError[Task](
      Throwable("error")
    )).toZStream()
    stream.runCollect
  }
}
@michalliss michalliss changed the title FS2 to ZStream: implicit errors are not propagated FS2 to ZStream: implicit errors are not propagated, stream hangs forever Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant