@@ -13,7 +13,8 @@ import 'package:vm_service/vm_service.dart';
13
13
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' ;
14
14
15
15
import 'events.dart' ;
16
- import 'services/chrome_proxy_service.dart' show ChromeProxyService;
16
+ import 'services/chrome_proxy_service.dart' ;
17
+ import 'services/chrome_debug_exception.dart' ;
17
18
import 'services/debug_service.dart' ;
18
19
19
20
final _logger = Logger ('DwdsVmClient' );
@@ -187,10 +188,9 @@ Future<Map<String, dynamic>> _hotRestart(
187
188
188
189
chromeProxyService.terminatingIsolates = true ;
189
190
await _disableBreakpointsAndResume (client, chromeProxyService);
190
- int context;
191
191
try {
192
192
_logger.info ('Attempting to get execution context ID.' );
193
- context = await chromeProxyService.executionContext.id;
193
+ await chromeProxyService.executionContext.id;
194
194
_logger.info ('Got execution context ID.' );
195
195
} on StateError catch (e) {
196
196
// We couldn't find the execution context. `hotRestart` may have been
@@ -209,12 +209,9 @@ Future<Map<String, dynamic>> _hotRestart(
209
209
// Generate run id to hot restart all apps loaded into the tab.
210
210
final runId = const Uuid ().v4 ().toString ();
211
211
_logger.info ('Issuing \$ dartHotRestartDwds request' );
212
- await chromeProxyService.remoteDebugger
213
- .sendCommand ('Runtime.evaluate' , params: {
214
- 'expression' : '\$ dartHotRestartDwds(\' $runId \' );' ,
215
- 'awaitPromise' : true ,
216
- 'contextId' : context,
217
- });
212
+ await chromeProxyService
213
+ .appInspectorProvider ()
214
+ .jsEvaluate ('\$ dartHotRestartDwds(\' $runId \' );' , awaitPromise: true );
218
215
_logger.info ('\$ dartHotRestartDwds request complete.' );
219
216
} on WipError catch (exception) {
220
217
final code = exception.error['code' ];
@@ -229,6 +226,14 @@ Future<Map<String, dynamic>> _hotRestart(
229
226
}
230
227
};
231
228
}
229
+ } on ChromeDebugException catch (exception) {
230
+ // Exceptions thrown by the injected client during hot restart.
231
+ return {
232
+ 'error' : {
233
+ 'code' : RPCError .kInternalError,
234
+ 'message' : '$exception ' ,
235
+ }
236
+ };
232
237
}
233
238
234
239
_logger.info ('Waiting for Isolate Start event.' );
0 commit comments