@@ -8,9 +8,9 @@ import 'dart:io';
88
99import 'package:build_daemon/data/build_status.dart' ;
1010import 'package:dwds/service.dart' ;
11+ import 'package:pedantic/pedantic.dart' ;
1112import 'package:vm_service_lib/vm_service_lib.dart' ;
1213
13- import '../serve/chrome.dart' ;
1414import '../serve/debugger/app_debug_services.dart' ;
1515import '../serve/server_manager.dart' ;
1616import 'daemon.dart' ;
@@ -70,6 +70,18 @@ class AppDomain extends Domain {
7070 _appDebugServices = await devHandler.loadAppServices (
7171 connection.request.appId, connection.request.instanceId);
7272 _appId = connection.request.appId;
73+ unawaited (_appDebugServices
74+ .debugService.chromeProxyService.tabConnection.onClose.first
75+ .then ((_) {
76+ sendEvent ('app.log' , {
77+ 'appId' : _appId,
78+ 'log' : 'Lost connection to device.' ,
79+ });
80+ sendEvent ('app.stop' , {
81+ 'appId' : _appId,
82+ });
83+ daemon.shutdown ();
84+ }));
7385 sendEvent ('app.start' , {
7486 'appId' : _appId,
7587 'directory' : Directory .current.path,
@@ -165,8 +177,8 @@ class AppDomain extends Domain {
165177 Future <bool > _stop (Map <String , dynamic > args) async {
166178 var appId = getStringArg (args, 'appId' , required : true );
167179 if (_appId != appId) throw ArgumentError .value (appId, 'appId' , 'Not found' );
168- var chrome = await Chrome .connectedInstance;
169- await chrome .close ();
180+ await _appDebugServices.debugService.chromeProxyService.tabConnection
181+ .close ();
170182 return true ;
171183 }
172184
0 commit comments