As noticed during #4625, Resource.eval seems to have an extra cancellation point at the end. I think it shouldn't. Minimization:
"Resource.eval" in real {
val test = Resource
.eval(IO.uncancelable(_ => IO.sleep(100.millis)))
.timeout(10.millis)
.use_
test.as(ok)
}
This fails with the 10.millis timeout. (Note: it passes with Resource.make.) Resource.eval is documented to "preserve interruptibility of fa". Which is very much uncancellable here. Yet, it is very much cancelled. (Or rather, it is cancelled right after the uncancelable ends, I think.) The crucial points in the code seem to be:
|
fa.flatMap(a => continue(Resource.pure(a), stack)) |
|
fa.flatMap(a => continue(Resource.pure(a), stack, release)) |
The obvious fix, i.e., F.uncancelable { poll => poll(fa).flatMap(a => ...) makes a lot of existing law tests fail, so more investigation is needed.
As noticed during #4625,
Resource.evalseems to have an extra cancellation point at the end. I think it shouldn't. Minimization:This fails with the 10.millis timeout. (Note: it passes with
Resource.make.)Resource.evalis documented to "preserve interruptibility offa". Which is very much uncancellable here. Yet, it is very much cancelled. (Or rather, it is cancelled right after theuncancelableends, I think.) The crucial points in the code seem to be:cats-effect/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala
Line 193 in a48cac0
cats-effect/kernel/shared/src/main/scala/cats/effect/kernel/Resource.scala
Line 527 in a48cac0
The obvious fix, i.e.,more investigation is needed.F.uncancelable { poll => poll(fa).flatMap(a => ...)makes a lot of existing law tests fail, so