Skip to content

Commit 3370a4e

Browse files
iinozemtsevCommit Queue
authored and
Commit Queue
committed
Revert "Reapply "[ Service ] Start DDS and serve DevTools when the VM service is started via dart:developer""
This reverts commit 44d4451. Reason for revert: b/350443042 Original change's description: > Reapply "[ Service ] Start DDS and serve DevTools when the VM service is started via dart:developer" > > In the previous version of this change, if the user had 'dart' on their > PATH and invoked 'dart compile js' (which spawns the VM service after > compilation completes), the VM service would attempt to spawn DDS using > './dart' as the executable path instead of 'dart'. This would result in > DDS failing to start, causing the VM to print an error and hang. > > This updated change checks to see if the parent directory of > `Platform.executable` is '.' and then verifies if './dart' exists or > not. If it doesn't, 'dart' is likely on the user's PATH and should be > used directly as the executable path. > > See #56087 for details. > > This reverts commit 4b88698. > > TEST=pkg/dds/test/control_web_server_starts_dds_with_dart_on_path_test.dart > > Change-Id: Id0f1dadd01d9202cbf7717f31393b43171cf3968 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373561 > Auto-Submit: Ben Konyi <[email protected]> > Reviewed-by: Derek Xu <[email protected]> > Commit-Queue: Ben Konyi <[email protected]> Change-Id: I424c4b91b0b108ae4c9dffa0059ed90c918897e3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373744 Reviewed-by: Siva Annamalai <[email protected]> Bot-Commit: Rubber Stamper <[email protected]> Reviewed-by: Srujan Gaddam <[email protected]> Commit-Queue: Siva Annamalai <[email protected]> Auto-Submit: Ivan Inozemtsev <[email protected]>
1 parent 9f27bde commit 3370a4e

File tree

4 files changed

+45
-155
lines changed

4 files changed

+45
-155
lines changed

pkg/dds/test/control_web_server_starts_dds_test.dart

Lines changed: 0 additions & 52 deletions
This file was deleted.

pkg/dds/test/control_web_server_starts_dds_with_dart_on_path_test.dart

Lines changed: 0 additions & 56 deletions
This file was deleted.

runtime/observatory/tests/service/developer_server_control_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Uri? wsServerUri;
1515

1616
Future<Null> testeeBefore() async {
1717
print('testee before');
18-
// First grab the URL where the VM service is listening and the
18+
// First grab the URL where the observatory is listening on and the
1919
// service protocol version numbers. We expect the URL to be null as
2020
// the server has not been started yet.
2121
ServiceProtocolInfo info = await Service.getInfo();

sdk/lib/_internal/vm/bin/vmservice_io.dart

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,11 @@ class _DebuggingSession {
9696
bool disableServiceAuthCodes,
9797
bool enableDevTools,
9898
) async {
99-
final dartDir = File(Platform.executable).parent.path;
100-
final dart = 'dart${Platform.isWindows ? '.exe' : ''}';
101-
var executable = [
99+
final dartDir = File(Platform.resolvedExecutable).parent.path;
100+
final executable = [
102101
dartDir,
103-
dart,
102+
'dart${Platform.isWindows ? '.exe' : ''}',
104103
].join(Platform.pathSeparator);
105-
106-
// If the directory of dart is '.' it's likely that dart is on the user's
107-
// PATH. If so, './dart' might not exist and we should be using 'dart'
108-
// instead.
109-
if (dartDir == '.' &&
110-
(await FileSystemEntity.type(executable)) ==
111-
FileSystemEntityType.notFound) {
112-
executable = dart;
113-
}
114104
_process = await Process.start(
115105
executable,
116106
[
@@ -143,15 +133,15 @@ class _DebuggingSession {
143133
// is changed to ensure consistency.
144134
const devToolsMessagePrefix =
145135
'The Dart DevTools debugger and profiler is available at:';
146-
serverPrint('$devToolsMessagePrefix $devToolsUri');
136+
print('$devToolsMessagePrefix $devToolsUri');
147137
}
148138
if (result
149139
case {
150140
'dtd': {
151141
'uri': String dtdUri,
152142
}
153143
} when _printDtd) {
154-
serverPrint('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
144+
print('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
155145
}
156146
} else {
157147
printError(result['error'] ?? result);
@@ -318,37 +308,18 @@ Future<List<Map<String, dynamic>>> listFilesCallback(Uri dirPath) async {
318308

319309
Uri? serverInformationCallback() => _lazyServerBoot().serverAddress;
320310

321-
Future<void> _toggleWebServer(Server server) async {
322-
// Toggle HTTP server.
323-
if (server.running) {
324-
await server.shutdown(true).then((_) async {
325-
ddsInstance?.shutdown();
326-
ddsInstance = null;
327-
await VMService().clearState();
328-
serverFuture = null;
329-
});
330-
} else {
331-
await server.startup().then((_) async {
332-
if (_waitForDdsToAdvertiseService) {
333-
ddsInstance = _DebuggingSession();
334-
await ddsInstance!.start(
335-
_ddsIP,
336-
_ddsPort.toString(),
337-
_authCodesDisabled,
338-
_serveDevtools,
339-
);
340-
}
341-
});
342-
}
343-
}
344-
345311
Future<Uri?> webServerControlCallback(bool enable, bool? silenceOutput) async {
346312
if (silenceOutput != null) {
347313
silentObservatory = silenceOutput;
348314
}
349315
final _server = _lazyServerBoot();
350316
if (_server.running != enable) {
351-
await _toggleWebServer(_server);
317+
if (enable) {
318+
await _server.startup();
319+
// TODO: if dds is enabled a dds instance needs to be started.
320+
} else {
321+
await _server.shutdown(true);
322+
}
352323
}
353324
return _server.serverAddress;
354325
}
@@ -358,13 +329,32 @@ void webServerAcceptNewWebSocketConnections(bool enable) {
358329
_server.acceptNewWebSocketConnections = enable;
359330
}
360331

361-
Future<void> _onSignal(ProcessSignal signal) async {
332+
_onSignal(ProcessSignal signal) async {
362333
if (serverFuture != null) {
363334
// Still waiting.
364335
return;
365336
}
366-
final server = _lazyServerBoot();
367-
await _toggleWebServer(server);
337+
final _server = _lazyServerBoot();
338+
// Toggle HTTP server.
339+
if (_server.running) {
340+
_server.shutdown(true).then((_) async {
341+
ddsInstance?.shutdown();
342+
await VMService().clearState();
343+
serverFuture = null;
344+
});
345+
} else {
346+
_server.startup().then((_) {
347+
if (_waitForDdsToAdvertiseService) {
348+
ddsInstance = _DebuggingSession()
349+
..start(
350+
_ddsIP,
351+
_ddsPort.toString(),
352+
_authCodesDisabled,
353+
_serveDevtools,
354+
);
355+
}
356+
});
357+
}
368358
}
369359

370360
Timer? _registerSignalHandlerTimer;
@@ -410,10 +400,18 @@ main() {
410400
// can be delivered and waiting loaders can be cancelled.
411401
VMService();
412402
if (_autoStart) {
413-
assert(server == null);
414403
final _server = _lazyServerBoot();
415-
assert(!_server.running);
416-
_toggleWebServer(_server);
404+
_server.startup().then((_) {
405+
if (_waitForDdsToAdvertiseService) {
406+
ddsInstance = _DebuggingSession()
407+
..start(
408+
_ddsIP,
409+
_ddsPort.toString(),
410+
_authCodesDisabled,
411+
_serveDevtools,
412+
);
413+
}
414+
});
417415
// It's just here to push an event on the event loop so that we invoke the
418416
// scheduled microtasks.
419417
Timer.run(() {});

0 commit comments

Comments
 (0)