Skip to content

Commit 256dce9

Browse files
author
Anna Gringauze
authored
Optimize url encoding, use default port for debugger service (#1402)
1 parent ee356b3 commit 256dce9

File tree

7 files changed

+126
-134
lines changed

7 files changed

+126
-134
lines changed

dwds/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## 11.3.1-dev
22

3+
- Encode extension url asynchronously.
4+
- Use default constant port for debug service.
5+
- If we fail binding to the port, fall back to previous strategy
6+
of finding unbound ports.
37
- Add metrics measuring DevTools Initial Page Load time.
48
- Add `ext.dwds.sendEvent` service extension to dwds so other tools
59
can send events to the debugger.

dwds/lib/dwds.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class Dwds {
121121
globalLoadStrategy = loadStrategy;
122122

123123
DevTools devTools;
124-
String extensionUri;
124+
Future<String> extensionUri;
125125
ExtensionBackend extensionBackend;
126126
if (enableDebugExtension) {
127127
final handler = useSseForDebugBackend
@@ -134,13 +134,13 @@ class Dwds {
134134
: WebSocketSocketHandler();
135135

136136
extensionBackend = await ExtensionBackend.start(handler, hostname);
137-
extensionUri = Uri(
137+
extensionUri = Future.value(Uri(
138138
scheme: useSseForDebugBackend ? 'http' : 'ws',
139139
host: extensionBackend.hostname,
140140
port: extensionBackend.port,
141141
path: r'$debug')
142-
.toString();
143-
if (urlEncoder != null) extensionUri = await urlEncoder(extensionUri);
142+
.toString());
143+
if (urlEncoder != null) extensionUri = urlEncoder(await extensionUri);
144144
}
145145

146146
var serveDevTools = devtoolsLauncher != null;

dwds/lib/src/handlers/injector.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ const _clientScript = 'dwds/src/injected/client';
3333
/// information.
3434
class DwdsInjector {
3535
final LoadStrategy _loadStrategy;
36-
final String _extensionUri;
36+
final Future<String> _extensionUri;
3737
final _devHandlerPaths = StreamController<String>();
3838
final _logger = Logger('DwdsInjector');
3939
final bool _enableDevtoolsLaunch;
4040
final bool _useSseForInjectedClient;
4141

4242
DwdsInjector(
4343
this._loadStrategy, {
44-
String extensionUri,
44+
Future<String> extensionUri,
4545
bool enableDevtoolsLaunch,
4646
bool useSseForInjectedClient,
4747
}) : _extensionUri = extensionUri,
@@ -104,7 +104,7 @@ class DwdsInjector {
104104
appId,
105105
devHandlerPath,
106106
entrypoint,
107-
_extensionUri,
107+
await _extensionUri,
108108
_loadStrategy,
109109
_enableDevtoolsLaunch,
110110
);

0 commit comments

Comments
 (0)