Add a switch to use WebSockets for web debug proxy (#54083)
diff --git a/packages/flutter_tools/lib/src/build_runner/devfs_web.dart b/packages/flutter_tools/lib/src/build_runner/devfs_web.dart index 67efb90..57341bc 100644 --- a/packages/flutter_tools/lib/src/build_runner/devfs_web.dart +++ b/packages/flutter_tools/lib/src/build_runner/devfs_web.dart
@@ -131,6 +131,7 @@ String hostname, int port, UrlTunneller urlTunneller, + bool useSseForDebugProxy, BuildMode buildMode, bool enableDwds, Uri entrypoint, @@ -210,6 +211,7 @@ }, urlEncoder: urlTunneller, enableDebugging: true, + useSseForDebugProxy: useSseForDebugProxy, serveDevTools: false, logWriter: (Level logLevel, String message) => globals.printTrace(message), loadStrategy: RequireStrategy( @@ -550,6 +552,7 @@ @required this.port, @required this.packagesFilePath, @required this.urlTunneller, + @required this.useSseForDebugProxy, @required this.buildMode, @required this.enableDwds, @required this.entrypoint, @@ -562,6 +565,7 @@ final int port; final String packagesFilePath; final UrlTunneller urlTunneller; + final bool useSseForDebugProxy; final BuildMode buildMode; final bool enableDwds; final bool testMode; @@ -623,6 +627,7 @@ hostname, port, urlTunneller, + useSseForDebugProxy, buildMode, enableDwds, entrypoint,
diff --git a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart index 6131a26..777a67e 100644 --- a/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
@@ -423,6 +423,7 @@ port: hostPort, packagesFilePath: packagesFilePath, urlTunneller: urlTunneller, + useSseForDebugProxy: debuggingOptions.webUseSseForDebugProxy, buildMode: debuggingOptions.buildInfo.mode, enableDwds: _enableDwds, entrypoint: globals.fs.file(target).uri,
diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 5d5a4b5..56b0af3 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart
@@ -351,6 +351,7 @@ initializePlatform: boolArg('web-initialize-platform'), hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '', port: featureFlags.isWebEnabled ? stringArg('web-port') : '', + webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArg('web-server-debug-protocol') == 'sse', webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'), webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'), webBrowserDebugPort: browserDebugPort, @@ -376,6 +377,7 @@ initializePlatform: boolArg('web-initialize-platform'), hostname: featureFlags.isWebEnabled ? stringArg('web-hostname') : '', port: featureFlags.isWebEnabled ? stringArg('web-port') : '', + webUseSseForDebugProxy: featureFlags.isWebEnabled && stringArg('web-server-debug-protocol') == 'sse', webEnableExposeUrl: featureFlags.isWebEnabled && boolArg('web-allow-expose-url'), webRunHeadless: featureFlags.isWebEnabled && boolArg('web-run-headless'), webBrowserDebugPort: browserDebugPort,
diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 85309ff..b5a54fb 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart
@@ -585,6 +585,7 @@ this.hostname, this.port, this.webEnableExposeUrl, + this.webUseSseForDebugProxy = true, this.webRunHeadless = false, this.webBrowserDebugPort, this.vmserviceOutFile, @@ -596,6 +597,7 @@ this.port, this.hostname, this.webEnableExposeUrl, + this.webUseSseForDebugProxy = true, this.webRunHeadless = false, this.webBrowserDebugPort, this.cacheSkSL = false, @@ -640,6 +642,7 @@ final String port; final String hostname; final bool webEnableExposeUrl; + final bool webUseSseForDebugProxy; /// Whether to run the browser in headless mode. ///
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index a6d7d2b..f90d8ef 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -168,6 +168,15 @@ 'will select a random open port on the host.', hide: hide, ); + argParser.addOption('web-server-debug-protocol', + allowed: <String>['sse', 'ws'], + defaultsTo: 'sse', + help: 'The protocol (SSE or WebSockets) to use for the debug service proxy ' + 'when using the Web Server device and Dart Debugger extension. ' + 'This is useful for editors/debug adapters that do not support debugging ' + 'over SSE (the default protocol for Web Server/Dart Debugger extension).', + hide: hide, + ); argParser.addFlag('web-allow-expose-url', defaultsTo: false, help: 'Enables daemon-to-editor requests (app.exposeUrl) for exposing URLs '