Repository navigation
[flutter_tools] Wait for TCP server socket to close in DaemonServer.run() - #193714
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the DaemonServer to wait for the server socket stream to close by awaiting subscription.asFuture() before cancelling the subscription, and adds a corresponding test. The review feedback suggests wrapping the await in a try-finally block to ensure the subscription is always cancelled even if an error occurs on the stream.
| await subscription.asFuture<void>(); | ||
| await subscription.cancel(); |
There was a problem hiding this comment.
If an error occurs on the stream, subscription.asFuture<void>() will complete with that error immediately. Since cancelOnError is false by default, the subscription will remain active and leak resources because subscription.cancel() is bypassed when the error is thrown.
Wrapping the await in a try-finally block ensures that the subscription is always properly cancelled.
try {
await subscription.asFuture<void>();
} finally {
await subscription.cancel();
}|
@bkonyi - This reverts your change, which I think was unintentional. Please take a look. |
bkonyi
left a comment
There was a problem hiding this comment.
Thanks for catching this and adding a test!
|
autosubmit label was removed for flutter/flutter/193714, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
Restores
await subscription.asFuture<void>();beforeawait subscription.cancel();inDaemonServer.run(), which was inadvertently removed in #192830. Without awaiting the subscription future,flutter daemon --listen-on-tcp-portimmediately cancels theServerSocketlistener and exits right after binding.Part of #188471
Pre-launch Checklist
///).