Unverified Commit 589b14d8 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Add a switch to use WebSockets for web debug proxy (#54083)

parent 981afe39
......@@ -131,6 +131,7 @@ class WebAssetServer implements AssetReader {
String hostname,
int port,
UrlTunneller urlTunneller,
bool useSseForDebugProxy,
BuildMode buildMode,
bool enableDwds,
Uri entrypoint,
......@@ -210,6 +211,7 @@ class WebAssetServer implements AssetReader {
},
urlEncoder: urlTunneller,
enableDebugging: true,
useSseForDebugProxy: useSseForDebugProxy,
serveDevTools: false,
logWriter: (Level logLevel, String message) => globals.printTrace(message),
loadStrategy: RequireStrategy(
......@@ -550,6 +552,7 @@ class WebDevFS implements DevFS {
@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 @@ class WebDevFS implements DevFS {
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 @@ class WebDevFS implements DevFS {
hostname,
port,
urlTunneller,
useSseForDebugProxy,
buildMode,
enableDwds,
entrypoint,
......
......@@ -423,6 +423,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
port: hostPort,
packagesFilePath: packagesFilePath,
urlTunneller: urlTunneller,
useSseForDebugProxy: debuggingOptions.webUseSseForDebugProxy,
buildMode: debuggingOptions.buildInfo.mode,
enableDwds: _enableDwds,
entrypoint: globals.fs.file(target).uri,
......
......@@ -351,6 +351,7 @@ class RunCommand extends RunCommandBase {
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 @@ class RunCommand extends RunCommandBase {
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,
......
......@@ -585,6 +585,7 @@ class DebuggingOptions {
this.hostname,
this.port,
this.webEnableExposeUrl,
this.webUseSseForDebugProxy = true,
this.webRunHeadless = false,
this.webBrowserDebugPort,
this.vmserviceOutFile,
......@@ -596,6 +597,7 @@ class DebuggingOptions {
this.port,
this.hostname,
this.webEnableExposeUrl,
this.webUseSseForDebugProxy = true,
this.webRunHeadless = false,
this.webBrowserDebugPort,
this.cacheSkSL = false,
......@@ -640,6 +642,7 @@ class DebuggingOptions {
final String port;
final String hostname;
final bool webEnableExposeUrl;
final bool webUseSseForDebugProxy;
/// Whether to run the browser in headless mode.
///
......
......@@ -168,6 +168,15 @@ abstract class FlutterCommand extends Command<void> {
'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 '
......
......@@ -376,6 +376,7 @@ void main() {
port: 0,
packagesFilePath: '.packages',
urlTunneller: null,
useSseForDebugProxy: true,
buildMode: BuildMode.debug,
enableDwds: false,
entrypoint: Uri.base,
......@@ -445,6 +446,7 @@ void main() {
'localhost',
8123,
(String url) => null,
true,
BuildMode.debug,
true,
Uri.file('test.dart'),
......@@ -468,11 +470,12 @@ void main() {
expect(verbose, null);
expect(enableDebugging, true);
expect(enableDebugExtension, true);
expect(useSseForDebugProxy, true);
return MockDwds();
});
await server.dispose();
await server.dispose();
}));
}
......
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