Accumulated `cats.data.WriterT` data not preserved from function passed to `fs2.io.readOutputStream`
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.5k
- Forks
- 636
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 7
Description
When using fs2.io.readOutputStream in combination with an effect type that uses cats.data.WriterT, any data accumulated in the function passed to fs2.io.readOutputStream is not preserved. For example, I would expect the list of strings produced by this code to include both "string 1" and "string 2", but I only get "string 2":
import cats.data.WriterT
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import fs2.io.readOutputStream
readOutputStream[WriterT[IO, List[String], *]](1024)(o => WriterT(IO((List("string 1"), o.write("a".getBytes("UTF-8"))))))
.evalMap(x => WriterT(IO.pure((List("string 2"), x))))
.compile
.drain
.run
.unsafeRunSync()
// (List("string 2"), ())
I can reproduce the issue using this code (available in this repo: https://github.com/mrdziuban/fs2-readOutputStream-WriterT) on both v2.5.10 and v3.2.4.
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 fs2.io.readOutputStream entry point and reproduce the behavior using the WriterT example from the issue on the affected versions. Trace how the effect returned by the supplied function is evaluated and how its accumulated data is combined. Done means the result preserves both "string 1" and "string 2".
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
- Mostly clear
- Newbie friendliness
- 35/100