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

Sbt main process cancelation seems broken with timers

Open djspiewak opened this issue 4 years ago • 4 comments

#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.

djspiewak avatar Aug 21 '21 00:08 djspiewak

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)
}

armanbilge avatar May 06 '23 02:05 armanbilge

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

armanbilge avatar May 06 '23 05:05 armanbilge

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.

djspiewak avatar May 06 '23 15:05 djspiewak

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 🤔

armanbilge avatar May 06 '23 15:05 armanbilge