Skip to content

Commit 15c1451

Browse files
authored
[ DWDS ] Spawn DDS in a process rather than using package:dds (#2466)
This is part of the effort to stop shipping DDS via Pub.
1 parent f0ae463 commit 15c1451

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Hide more variables from the local scope when debugging. These variables were synthetically added by the compiler to
88
support late local variables and don't appear in the original source code. - [#2445](https://github.com/dart-lang/webdev/pull/2445)
99
- Require Dart `^3.4`
10+
- Spawn DDS in a separate process using `dart development-service` instead of launching from `package:dds`. - [#2466](https://github.com/dart-lang/webdev/pull/2466)
1011

1112
## 24.0.0
1213

dwds/lib/src/services/debug_service.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:io';
88
import 'dart:math';
99
import 'dart:typed_data';
1010

11-
import 'package:dds/dds.dart';
11+
import 'package:dds/dds_launcher.dart';
1212
import 'package:dwds/src/config/tool_configuration.dart';
1313
import 'package:dwds/src/connections/app_connection.dart';
1414
import 'package:dwds/src/debugging/execution_context.dart';
@@ -27,6 +27,8 @@ import 'package:sse/server/sse_handler.dart';
2727
import 'package:vm_service_interface/vm_service_interface.dart';
2828
import 'package:web_socket_channel/web_socket_channel.dart';
2929

30+
const _kSseHandlerPath = '\$debugHandler';
31+
3032
bool _acceptNewConnections = true;
3133
int _clientsConnected = 0;
3234

@@ -136,7 +138,7 @@ class DebugService {
136138
final bool _useSse;
137139
final bool _spawnDds;
138140
final UrlEncoder? _urlEncoder;
139-
DartDevelopmentService? _dds;
141+
DartDevelopmentServiceLauncher? _dds;
140142

141143
/// Null until [close] is called.
142144
///
@@ -160,11 +162,11 @@ class DebugService {
160162
if (_dds != null) _dds!.shutdown(),
161163
]);
162164

163-
Future<DartDevelopmentService> startDartDevelopmentService() async {
165+
Future<DartDevelopmentServiceLauncher> startDartDevelopmentService() async {
164166
// Note: DDS can handle both web socket and SSE connections with no
165167
// additional configuration.
166-
_dds = await DartDevelopmentService.startDartDevelopmentService(
167-
Uri(
168+
_dds = await DartDevelopmentServiceLauncher.start(
169+
remoteVmServiceUri: Uri(
168170
scheme: 'http',
169171
host: hostname,
170172
port: port,
@@ -175,7 +177,6 @@ class DebugService {
175177
host: hostname,
176178
port: 0,
177179
),
178-
ipv6: await useIPv6ForHost(hostname),
179180
);
180181
return _dds!;
181182
}
@@ -248,7 +249,7 @@ class DebugService {
248249
// DDS will always connect to DWDS via web sockets.
249250
if (useSse && !spawnDds) {
250251
final sseHandler = SseHandler(
251-
Uri.parse('/$authToken/\$debugHandler'),
252+
Uri.parse('/$authToken/$_kSseHandlerPath'),
252253
keepAlive: const Duration(seconds: 5),
253254
);
254255
handler = sseHandler.handler;

dwds/lib/src/utilities/server.dart

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ import 'package:stack_trace/stack_trace.dart';
1212
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart'
1313
as wip;
1414

15-
/// Returns `true` if [hostname] is bound to an IPv6 address.
16-
Future<bool> useIPv6ForHost(String hostname) async {
17-
final addresses = await InternetAddress.lookup(hostname);
18-
if (addresses.isEmpty) return false;
19-
final address = addresses.firstWhere(
20-
(a) => a.type == InternetAddressType.IPv6,
21-
orElse: () => addresses.first,
22-
);
23-
return address.type == InternetAddressType.IPv6;
24-
}
25-
2615
/// Returns a port that is probably, but not definitely, not in use.
2716
///
2817
/// This has a built-in race condition: another process may bind this port at

dwds/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
built_value: ^8.3.0
1515
collection: ^1.15.0
1616
crypto: ^3.0.2
17-
dds: ^4.1.0
17+
dds: ^4.2.5
1818
file: ">=6.1.4 <8.0.0"
1919
http: ^1.0.0
2020
http_multi_server: ^3.2.0

0 commit comments

Comments
 (0)