Unverified Commit ca789bf5 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] bail from printing if devtools launch fails (#83934)

parent c6359dc9
...@@ -82,6 +82,10 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler { ...@@ -82,6 +82,10 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
_served = true; _served = true;
} }
await _devToolsLauncher.ready; await _devToolsLauncher.ready;
// Do not attempt to print debugger list if the connection has failed.
if (_devToolsLauncher.activeDevToolsServer == null) {
return;
}
final List<FlutterDevice> devicesWithExtension = await _devicesWithExtensions(flutterDevices); final List<FlutterDevice> devicesWithExtension = await _devicesWithExtensions(flutterDevices);
await _maybeCallDevToolsUriServiceExtension(devicesWithExtension); await _maybeCallDevToolsUriServiceExtension(devicesWithExtension);
await _callConnectedVmServiceUriExtension(devicesWithExtension); await _callConnectedVmServiceUriExtension(devicesWithExtension);
......
...@@ -192,6 +192,22 @@ void main() { ...@@ -192,6 +192,22 @@ void main() {
); );
}); });
testWithoutContext('serveAndAnnounceDevTools will bail if launching devtools fails', () async {
final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler(
FakeDevtoolsLauncher()..activeDevToolsServer = null,
FakeResidentRunner(),
BufferLogger.test(),
);
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[], httpAddress: Uri.parse('http://localhost:1234'));
final FakeFlutterDevice device = FakeFlutterDevice()
..vmService = fakeVmServiceHost.vmService;
await handler.serveAndAnnounceDevTools(
flutterDevices: <FlutterDevice>[device],
);
});
testWithoutContext('serveAndAnnounceDevTools with web device', () async { testWithoutContext('serveAndAnnounceDevTools with web device', () async {
final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler( final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler(
FakeDevtoolsLauncher()..activeDevToolsServer = DevToolsServerAddress('localhost', 8080), FakeDevtoolsLauncher()..activeDevToolsServer = DevToolsServerAddress('localhost', 8080),
......
...@@ -1926,7 +1926,6 @@ void main() { ...@@ -1926,7 +1926,6 @@ void main() {
FileSystem: () => ThrowingForwardingFileSystem(MemoryFileSystem.test()), FileSystem: () => ThrowingForwardingFileSystem(MemoryFileSystem.test()),
})); }));
testUsingContext('ColdRunner writes vm service file when providing debugging option', () => testbed.run(() async { testUsingContext('ColdRunner writes vm service file when providing debugging option', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[ fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews, listViews,
......
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