Unverified Commit a0860f6e authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

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

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.
parent 44d0e52d
......@@ -483,11 +483,6 @@ class _ResidentWebRunner extends ResidentWebRunner {
'Launching ${globals.fsUtils.getDisplayPath(target)} '
'on ${device.device.name} in $modeName mode...',
);
final String effectiveHostname = debuggingOptions.hostname ?? 'localhost';
final int hostPort = debuggingOptions.port == null
? await globals.os.findFreePort()
: int.tryParse(debuggingOptions.port);
if (device.device is ChromiumDevice) {
_chromiumLauncher = (device.device as ChromiumDevice).chromeLauncher;
}
......@@ -498,10 +493,11 @@ class _ResidentWebRunner extends ResidentWebRunner {
debuggingOptions.webEnableExpressionEvaluation
? WebExpressionCompiler(device.generator)
: null;
device.devFS = WebDevFS(
hostname: effectiveHostname,
port: hostPort,
hostname: debuggingOptions.hostname ?? 'localhost',
port: debuggingOptions.port != null
? int.tryParse(debuggingOptions.port)
: null,
packagesFilePath: packagesFilePath,
urlTunneller: urlTunneller,
useSseForDebugProxy: debuggingOptions.webUseSseForDebugProxy,
......
......@@ -699,7 +699,7 @@ void main() {
contains('GENERATED'));
// served on localhost
expect(uri, Uri.http('localhost:0', ''));
expect(uri.host, 'localhost');
await webDevFS.destroy();
}, overrides: <Type, Generator>{
......@@ -813,7 +813,7 @@ void main() {
contains('GENERATED'));
// served on localhost
expect(uri, Uri.http('localhost:0', ''));
expect(uri.host, 'localhost');
await webDevFS.destroy();
}, overrides: <Type, Generator>{
......@@ -859,7 +859,7 @@ void main() {
final Uri uri = await webDevFS.create();
expect(uri, Uri.http('localhost:0', ''));
expect(uri.host, 'localhost');
await webDevFS.destroy();
}));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment