Fix uncancellable reactive-streams StreamSubscriber#3446
Fix uncancellable reactive-streams StreamSubscriber#3446i-surkov wants to merge 1 commit intotypelevel:mainfrom
Conversation
191585b to
8405c21
Compare
| F.async[Either[Throwable, Option[Chunk[A]]]] { cb => | ||
| F.delay { | ||
| nextState(OnDequeue(out => cb(Right(out)))) | ||
| Some(F.unit) |
There was a problem hiding this comment.
Is the cleanup of the subscription handled around this effect? Producing Some(F.unit) basically says that there is no cleanup action which must be taken on the state resulting from nextState, and it actually corresponds to a memory leak unless we have a higher level guarantee of cleanup.
There was a problem hiding this comment.
The cleanup happens with the onFinalize call in the Streams.bracket here:
def stream(subscribe: F[Unit])(implicit ev: ApplicativeError[F, Throwable]): Stream[F, A] =
Stream.bracket(subscribe)(_ => onFinalize) >> Stream
.eval(dequeue1)
.repeat
.rethrow
.unNoneTerminate
.unchunkswhich is the only place where dequeue1 is used internally.
Although technically I guess someone could call StreamSubscriber#sub.dequeue1 directly, since it is exposed here (unlike analogous flow interop).
8405c21 to
021a610
Compare
|
Hi @armanbilge, just checking if you will have some time to review this |
Fixes #3260.
Due to the changes in cats-effect
asynccancellation semantics,StreamSubscriber'sdequeue1became uncancellable, this PR fixes that.I've also added identical test cases for both
reactive-streamsandflowinterops which checks that the streams provided byStreamSubscriberis indeed interruptible (it failed forreactive-streamsbefore the fix), and that it does callcancel()on theSubscriptionwhen interrupted.