Fix uncancellable reactive-streams StreamSubscriber#3446
Open
i-surkov wants to merge 1 commit intotypelevel:mainfrom
Open
Fix uncancellable reactive-streams StreamSubscriber#3446i-surkov wants to merge 1 commit intotypelevel:mainfrom
i-surkov wants to merge 1 commit intotypelevel:mainfrom
Conversation
191585b to
8405c21
Compare
djspiewak
reviewed
Jun 20, 2024
| F.async[Either[Throwable, Option[Chunk[A]]]] { cb => | ||
| F.delay { | ||
| nextState(OnDequeue(out => cb(Right(out)))) | ||
| Some(F.unit) |
Member
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.
Author
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
Author
|
Hi @armanbilge, just checking if you will have some time to review this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.