Skip to content

[flutter_tools] retry sever socket setup (and port selection if port is unspecified) - #69351

Merged
jonahwilliams merged 5 commits into
flutter:masterfrom
jonahwilliams:retry_socket_setup
Oct 30, 2020
Merged

jonahwilliams merged 5 commits into
flutter:masterfrom
jonahwilliams:retry_socket_setup

Conversation

@jonahwilliams

Copy link
Copy Markdown
Contributor

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.

@flutter-dashboard flutter-dashboard Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Oct 30, 2020
@google-cla google-cla Bot added the cla: yes label Oct 30, 2020
@jonahwilliams jonahwilliams changed the title [flutter_tools] retry sever socket setup if port is unspecified [flutter_tools] retry sever socket setup (and port selection if port is unspecified) Oct 30, 2020

@yjbanov yjbanov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

}
HttpServer httpServer;
dynamic lastError;
for (int i = 0; i < 5; i += 1) {

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYM by permanent?

Copy link
Copy Markdown
Contributor Author

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;

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jonahwilliams
jonahwilliams merged commit a0860f6 into flutter:master Oct 30, 2020
@jonahwilliams
jonahwilliams deleted the retry_socket_setup branch October 30, 2020 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web flake in expression evaluation tests

2 participants