-
Notifications
You must be signed in to change notification settings - Fork 33
Fix StreamGroup.broadcast() close() not completing when streams close. #876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
90030eb
f1283f7
89dcb4e
cd2faf2
032a24b
ef32af5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,7 +289,34 @@ class StreamGroup<T> implements Sink<Stream<T>> { | |
if (_closed) return _controller.done; | ||
|
||
_closed = true; | ||
if (_subscriptions.isEmpty) _controller.close(); | ||
|
||
if (_subscriptions.isEmpty) { | ||
_onIdleController?.close(); | ||
lrhn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_controller.close(); | ||
return _controller.done; | ||
} | ||
|
||
if (_controller.stream.isBroadcast) { | ||
// For a broadcast group that's closed, we must listen to streams with | ||
// null subscriptions to detect when they complete. This ensures the | ||
// group itself can close once all its streams have closed. | ||
final streamsToRemove = <Stream<T>>[]; | ||
|
||
|
||
_subscriptions.updateAll((stream, subscription) { | ||
if (subscription != null) return subscription; | ||
|
||
try { | ||
return _listenToStream(stream); | ||
} on Object { | ||
streamsToRemove.add(stream); | ||
return null; | ||
} | ||
}); | ||
|
||
for (final stream in streamsToRemove) { | ||
_subscriptions.remove(stream); | ||
} | ||
} | ||
|
||
return _controller.done; | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to a
## 2.14.0-wip
entry, and update the pubspec.yaml version to match.
The 2.13.0 version has been released, so this fix won't be in it.
Can probably be a
2.13.1-wip
"bugfix". @natebosch WDYT?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it to 2.13.1-wip, Let me know if there are any other changes needed. Thanks!☺️
commit log: 032a24b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's looking good. It needs a second reviewer, so we can have a second opinion.