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

This commit is contained in:
Jonah Williams 2021-06-03 18:19:05 -07:00 committed by GitHub
parent c6359dc93f
commit ca789bf5a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View file

@ -82,6 +82,10 @@ class FlutterResidentDevtoolsHandler implements ResidentDevtoolsHandler {
_served = true;
}
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);
await _maybeCallDevToolsUriServiceExtension(devicesWithExtension);
await _callConnectedVmServiceUriExtension(devicesWithExtension);

View file

@ -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 {
final ResidentDevtoolsHandler handler = FlutterResidentDevtoolsHandler(
FakeDevtoolsLauncher()..activeDevToolsServer = DevToolsServerAddress('localhost', 8080),

View file

@ -1926,7 +1926,6 @@ void main() {
FileSystem: () => ThrowingForwardingFileSystem(MemoryFileSystem.test()),
}));
testUsingContext('ColdRunner writes vm service file when providing debugging option', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
listViews,