cats-effect
cats-effect copied to clipboard
Sbt main process cancelation seems broken with timers
#2250 illustrates a bit of an issue with the process cancelation in sbt when fork := false. For whatever reason, the fibers don't seem to be canceled entirely and the thread pools are not cleaned up. Needs verification and minimization.
Is this still relevant now that we've integrated timers in v3.5.0?
Update: reproduced with v3.4.10 and v3.5.0-RC5. Basically running something like this via sbt, canceling it, and then getting the println right-on-schedule anyway 😅
import cats.effect._
import scala.concurrent.duration._
object Test extends IOApp.Simple {
def run = IO(println("huh")).delayBy(10.seconds)
}
Seems that this isn't actually working—not sure how sbt is signaling cancelation, if at all 🤔 https://github.com/typelevel/cats-effect/blob/c00f3d01c34f5cf2fc52614c18b627c8fda9bfad/core/jvm/src/main/scala/cats/effect/IOApp.scala#L528-L530
There's a bug in sbt. I really should have written down the issue number the last time I rabbit holed on this, but sbt has genuinely stopped forwarding cancelation onto run tasks correctly. Basically, the line you just linked used to work in a prior version of Sbt, and it's supposed to still work, but it's dead code on current versions.
I found:
- https://github.com/sbt/sbt/issues/6242
which seems to mention this exact problem, but you closed it as a duplicate of:
- https://github.com/sbt/sbt/issues/6192
which I think was just about the annoying stacktrace 🤔