fs2
fs2 copied to clipboard
Exception in spawned stream cancels Stream.never but swallows the exception
Hi, I found an edge case which causes an exception to be swallowed while cancelling the stream.
The following snippet prints () which was pretty unexpected for me. I would have expected the stream to throw the RuntimeException or at least Stream.never to block the stream forever.
import cats.effect.{IO, IOApp}
import fs2.Stream
object Fs2Bug extends IOApp.Simple {
override def run: IO[Unit] =
Stream
.raiseError[IO](new RuntimeException())
.spawn
.flatMap(_ => Stream.never[IO])
.compile
.resource
.drain
.allocated
.map { case (r, _) => println(r) }
}
I tested this with v3.10.2 and v3.11.0