Ensure to close connection to VM after collecting coverage (#50943)

This commit is contained in:
Martin Kustermann
2020-02-18 21:39:37 +01:00
committed by GitHub
parent 11589ca20d
commit d2947571bd
3 changed files with 17 additions and 5 deletions

View File

@@ -181,7 +181,10 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool Function(String) libra
}) async {
final VMService vmService = await connector(serviceUri);
await vmService.getVM();
return _getAllCoverage(vmService, libraryPredicate);
final Map<String, dynamic> result = await _getAllCoverage(
vmService, libraryPredicate);
await vmService.close();
return result;
}
Future<Map<String, dynamic>> _getAllCoverage(VMService service, bool Function(String) libraryPredicate) async {

View File

@@ -452,6 +452,8 @@ class VMService {
Future<void> getVM() async => await vm.reload();
Future<void> refreshViews({ bool waitForViews = false }) => vm.refreshViews(waitForViews: waitForViews);
Future<void> close() async => await _peer.close();
}
/// An error that is thrown when constructing/updating a service object.