Last active
March 4, 2024 17:06
-
-
Save zainab-ali/03273f32e0fbbd59074e7058203623ac to your computer and use it in GitHub Desktop.
handleErrorWith OOMs on an infinite stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//> using scala "3.4.0" | |
//> using lib "co.fs2::fs2-core:3.9.4" | |
import fs2.* | |
import cats.effect.* | |
import cats.effect.unsafe.implicits.global | |
def infiniteStream: Stream[IO, Unit] = | |
(Stream.unit ++ infiniteStream) | |
.handleErrorWith(err => Stream.unit) | |
infiniteStream.compile.drain.unsafeRunSync() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment