Skip to content

Commit

Permalink
Revert "Reapply "[ Service ] Start DDS and serve DevTools when the VM…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
iinozemtsev authored and Commit Queue committed Jul 1, 2024
1 parent 9f27bde commit 3370a4e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 155 deletions.
52 changes: 0 additions & 52 deletions pkg/dds/test/control_web_server_starts_dds_test.dart

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Uri? wsServerUri;

Future<Null> testeeBefore() async {
print('testee before');
// First grab the URL where the VM service is listening and the
// First grab the URL where the observatory is listening on and the
// service protocol version numbers. We expect the URL to be null as
// the server has not been started yet.
ServiceProtocolInfo info = await Service.getInfo();
Expand Down
90 changes: 44 additions & 46 deletions sdk/lib/_internal/vm/bin/vmservice_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,11 @@ class _DebuggingSession {
bool disableServiceAuthCodes,
bool enableDevTools,
) async {
final dartDir = File(Platform.executable).parent.path;
final dart = 'dart${Platform.isWindows ? '.exe' : ''}';
var executable = [
final dartDir = File(Platform.resolvedExecutable).parent.path;
final executable = [
dartDir,
dart,
'dart${Platform.isWindows ? '.exe' : ''}',
].join(Platform.pathSeparator);

// If the directory of dart is '.' it's likely that dart is on the user's
// PATH. If so, './dart' might not exist and we should be using 'dart'
// instead.
if (dartDir == '.' &&
(await FileSystemEntity.type(executable)) ==
FileSystemEntityType.notFound) {
executable = dart;
}
_process = await Process.start(
executable,
[
Expand Down Expand Up @@ -143,15 +133,15 @@ class _DebuggingSession {
// is changed to ensure consistency.
const devToolsMessagePrefix =
'The Dart DevTools debugger and profiler is available at:';
serverPrint('$devToolsMessagePrefix $devToolsUri');
print('$devToolsMessagePrefix $devToolsUri');
}
if (result
case {
'dtd': {
'uri': String dtdUri,
}
} when _printDtd) {
serverPrint('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
print('The Dart Tooling Daemon (DTD) is available at: $dtdUri');
}
} else {
printError(result['error'] ?? result);
Expand Down Expand Up @@ -318,37 +308,18 @@ Future<List<Map<String, dynamic>>> listFilesCallback(Uri dirPath) async {

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

Future<void> _toggleWebServer(Server server) async {
// Toggle HTTP server.
if (server.running) {
await server.shutdown(true).then((_) async {
ddsInstance?.shutdown();
ddsInstance = null;
await VMService().clearState();
serverFuture = null;
});
} else {
await server.startup().then((_) async {
if (_waitForDdsToAdvertiseService) {
ddsInstance = _DebuggingSession();
await ddsInstance!.start(
_ddsIP,
_ddsPort.toString(),
_authCodesDisabled,
_serveDevtools,
);
}
});
}
}

Future<Uri?> webServerControlCallback(bool enable, bool? silenceOutput) async {
if (silenceOutput != null) {
silentObservatory = silenceOutput;
}
final _server = _lazyServerBoot();
if (_server.running != enable) {
await _toggleWebServer(_server);
if (enable) {
await _server.startup();
// TODO: if dds is enabled a dds instance needs to be started.
} else {
await _server.shutdown(true);
}
}
return _server.serverAddress;
}
Expand All @@ -358,13 +329,32 @@ void webServerAcceptNewWebSocketConnections(bool enable) {
_server.acceptNewWebSocketConnections = enable;
}

Future<void> _onSignal(ProcessSignal signal) async {
_onSignal(ProcessSignal signal) async {
if (serverFuture != null) {
// Still waiting.
return;
}
final server = _lazyServerBoot();
await _toggleWebServer(server);
final _server = _lazyServerBoot();
// Toggle HTTP server.
if (_server.running) {
_server.shutdown(true).then((_) async {
ddsInstance?.shutdown();
await VMService().clearState();
serverFuture = null;
});
} else {
_server.startup().then((_) {
if (_waitForDdsToAdvertiseService) {
ddsInstance = _DebuggingSession()
..start(
_ddsIP,
_ddsPort.toString(),
_authCodesDisabled,
_serveDevtools,
);
}
});
}
}

Timer? _registerSignalHandlerTimer;
Expand Down Expand Up @@ -410,10 +400,18 @@ main() {
// can be delivered and waiting loaders can be cancelled.
VMService();
if (_autoStart) {
assert(server == null);
final _server = _lazyServerBoot();
assert(!_server.running);
_toggleWebServer(_server);
_server.startup().then((_) {
if (_waitForDdsToAdvertiseService) {
ddsInstance = _DebuggingSession()
..start(
_ddsIP,
_ddsPort.toString(),
_authCodesDisabled,
_serveDevtools,
);
}
});
// It's just here to push an event on the event loop so that we invoke the
// scheduled microtasks.
Timer.run(() {});
Expand Down

0 comments on commit 3370a4e

Please sign in to comment.