-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[flutter_tools] retry sever socket setup (and port selection if port is unspecified) #69351
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
[flutter_tools] retry sever socket setup (and port selection if port is unspecified) #69351
Conversation
yjbanov
left a comment
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.
| } | ||
| HttpServer httpServer; | ||
| dynamic lastError; | ||
| for (int i = 0; i < 5; i += 1) { |
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.
If there's a way to tell that the SocketException is permament I'd do while (true)
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.
WDYM by permanent?
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 generally no, if another program is holding this port we likely can't tell when it will terminate
| httpServer = await HttpServer.bind(address, port ?? await globals.os.findFreePort()); | ||
| break; | ||
| } on SocketException catch (error) { | ||
| lastError = error; |
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.
Maybe insert await Future.delayed(Duration(milliseconds: 100)) or something? In case this is happening while something else is struggling to shut down?
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.
Done

Description
Fixes #69348
If the web development server fails to bind, then retry up to 5 times. If a port was not provided, select a new free port each time.