-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix parEvalMap getting stuck on exception #1311
Conversation
it would be good to have a test for this scenario, given that it's tricky, but if it's even trickier to write one, never mind |
@SystemFw I agree a test would be good, but I've been unable to produce one given it's relying on timing (queue has to fill up after dequeuing the element with the error, and for the |
@SystemFw Looks like there might be more issues at play here. While trying to get some tests together, I wrote this: import cats.effect.IO
class MapAsyncSpec extends Fs2Spec {
"mapAsync should terminate on exceptions" in {
Stream
.iterate(0)(_ + 1)
.covary[IO]
.mapAsync(1) { n =>
if (n == 5) IO.raiseError(new RuntimeException)
else IO.unit
}
.compile
.drain
.unsafeRunSync
}
} which hangs forever, even with the fix in this pull request. It looks like neither finalizers ever get invoked. If the |
Thanks for all the work on this Viktor :) I guess my next suggestion would be if you can reproduce with |
@SystemFw Thanks for the super quick reply! :) It looks like we're getting stuck in the finalizer from Edit: there seems to be a test case for Also, this small example: Stream.empty
.covary[IO]
.onFinalize(IO(println("1")))
.onFinalize(IO(println("2")))
.compile
.drain
.unsafeRunSync prints:
which is incorrect in my mind, as finalizers have to run in reverse order (or am I missing something?). (And just to confirm, Edit 2: looking at the definition of |
@SystemFw I've added a test case for the finalizer behaviour, which is what previously prevented stream interruption (and which prevented it when I got the order of the finalizers wrong above). It does not test that the blocking |
Fix #1297. Explanation is in #1297 (comment).