Closed ChenCMD closed 1 month ago
Scala - 3.5.1 fs2-core - 3.11.0 fs2-io - 3.11.0
import fs2.Stream import fs2.io.file.Files import fs2.io.file.Path import cats.effect.IO import cats.effect.unsafe.implicits.global @main def main: Unit = { val program = Stream .eval(IO { println("side-effect 1"); "out1" }) .append(Stream.eval(IO { println("side-effect 2"); "out2" })) .through(Files.forIO.writeUtf8Lines(Path("text.txt"))) .compile .drain program.unsafeRunSync() }
side-effect 1 side-effect 1 side-effect 2
side-effect 1 is output only once.
side-effect 1
side-effect 1 is output twice.
Version
Scala - 3.5.1 fs2-core - 3.11.0 fs2-io - 3.11.0
Minimized code
Console output
Expected result
side-effect 1
is output only once.Actual result
side-effect 1
is output twice.