cats-effect icon indicating copy to clipboard operation
cats-effect copied to clipboard

Racing Resource causes exception to be printed in standard error

Open lavrov opened this issue 3 years ago • 1 comments

Reproduction script (scala-cli):

//> using lib "org.typelevel::cats-effect:3.3.13"

import cats.effect.*

object Main extends IOApp.Simple:

  def run =
    Resource
      .eval(IO.raiseError(new Exception("Boom")))
      .race(Resource.never)
      .attempt
      .use(_ => 
        IO.println("Done")
      )

Running scala-cli run main.scala gives the following output:

java.lang.Exception: Boom
	at Main$.run(main.scala:9)
	at run$ @ Main$.run(main.scala:5)
Done

where exception stacktrace comes from standard error.

lavrov avatar Jul 10 '22 09:07 lavrov

Thanks for reporting. I think this may be related to https://github.com/typelevel/cats-effect/issues/2962 and https://github.com/typelevel/cats-effect/issues/3085.

armanbilge avatar Jul 10 '22 09:07 armanbilge

This still seems to be a problem as of 3.4.2. Maybe we can fix it as part of https://github.com/typelevel/cats-effect/pull/3226.

armanbilge avatar Dec 21 '22 13:12 armanbilge

@armanbilge Did we work around this with the specialized race implementation?

djspiewak avatar Feb 27 '23 17:02 djspiewak

Yup! Tried the reproducer with 3.4.2 and 3.4.3 when the new race implementation landed. The fix happened between there anyway :)

armanbilge avatar Feb 27 '23 17:02 armanbilge