Stream hangs on error with broadcastThrough and readOutputStream
Open
Nobody has claimed this yet.
bug
- Dominant language
- Scala
- Stars
- 2.5k
- Forks
- 636
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 7
Description
fs2 version: 3.11.0
scala version: 3.3.4
The following code snippet throws a java.util.NoSuchElementException: None.get, which means that the stream is hanging.
I expect it to throw java.lang.Exception: boom instead.
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import scala.concurrent.duration.DurationInt
fs2.Stream
.emit[IO, Byte](1)
.evalTap(_ => IO.raiseError(new Exception("boom")))
.broadcastThrough(in =>
fs2.io.readOutputStream(1) { out =>
in.evalMap(b => IO.interruptible(out.write(b))).compile.drain
}
)
.compile
.drain
.unsafeRunTimed(2.second)
.get
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied Scastie reproduction and inspect the interaction between broadcastThrough and readOutputStream, including the evalTap that raises the error. Confirm the stream no longer hangs or produces NoSuchElementException and instead propagates java.lang.Exception: boom.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- stream-processing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100