Fix scope leak with Stream.retry and in general, with pulls that do... #1885
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.
…not consume all elements from source.
Some observations prior to this PR:
The reason a leak was introduced in 2.1.0 is that
handleErrorWith
was modified to introduce a scope. The use ofhead
, which is an alias fortake(1)
, is implemented with a pull that discards the remainder of the stream once a single output element has been output. This has the effect of discarding the release of the scope opened byhandleErrorWith
.More generally, any pull which discards the remainder of the stream has the potential of causing a similar scope leak. Hence, this PR returns to the FS2 1.0.x design of introducing a scope every time a pull is converted to a stream. Doing so causes the scope introduced by
handleErrorWith
to be a child scope of the pull-to-stream scope, and hence, when the pull-to-stream scope is closed, all descendant scopes are closed too.