Open Swoorup opened 2 years ago
Initial guess is that this is example of badly interacting features -- concurrently
and .compile.resource
. That is, concurrently
introduces its own root scope which results in the scope from Stream.resource
no longer being a root scope, and hence not having its lifetime extended to the lifetime of the returned resource.
I have checked the test in scastie
. I have also tried changing versions, and it already happens with versions 2.5.1
and 2.5.6
of fs2
and cats-effect
.
I'll leave this comment here, it may be relevant(I see as
== map
in both examples).
https://github.com/typelevel/fs2/issues/2785#issuecomment-1007825447
It appears that resource finalizer is not being called correctly in order. In this simple example, almost all runs I did, the finalizer gets called before the last
.use
statementVersion: 3.2.8
Output:
https://scastie.scala-lang.org/NmxxGQjXREyyA3RflV9nqA