fix(bloc_concurrency): close droppable stream when source ends mid-event - #4829
Open
tonytonycoder11 wants to merge 1 commit into
Open
fix(bloc_concurrency): close droppable stream when source ends mid-event#4829tonytonycoder11 wants to merge 1 commit into
tonytonycoder11 wants to merge 1 commit into
Conversation
droppable()'s hand-written _ExhaustMapStreamTransformer never closed its output StreamController when the source stream completed while a mapped event handler was still in flight, so the transformed stream never emitted `done` (leaking the subscription and preventing a Bloc/Cubit closed mid-event from ever completing). Track source completion and close the output stream once the source is done and no event is in flight, matching the completion propagation of the sibling sequential/concurrent/restartable transformers. Adds a regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Status
READY
Breaking Changes
NO
Description
droppable()uses a hand-written_ExhaustMapStreamTransformerwhose outputStreamControlleris never closed when the source event stream completes while a mapped event handler is still in flight.onDone(() => mappedSubscription ?? controller.close()) intentionally defers closing while a mapped subscription is active, butonDone(() => mappedSubscription = null) only clears the reference and never re-checks whether the source has already completed.As a result the transformed stream never emits
done: the subscription leaks and aBloc/Cubitthat is closed while adroppableevent is being processed never completes. The sibling transformers all propagate source completion (sequential→asyncExpand,concurrent→concurrentAsyncExpand,restartable→switchMap), sodroppablewas the only outlier.This tracks source completion with an
isSourceDoneflag and closes the output controller once the source is done and no event is in flight (extracted into a smallmaybeClose()helper so the completion condition lives in one place):onDonefires.There is no public API change and no change to event-dropping, cancellation, or idle-completion behavior. A regression test covering the source-completes-mid-event path is included (it fails on
masterand passes with this change); the existing suite stays green at 100% coverage.Type of Change