@@ -146,6 +146,7 @@ class WebSocketProxyService implements VmServiceInterface {
146
146
vm_service.IsolateRef ? _isolateRef;
147
147
bool _isolateRunning = false ;
148
148
vm_service.Event ? _currentPauseEvent;
149
+ bool _mainHasStarted = false ;
149
150
150
151
/// Creates a new isolate for WebSocket debugging.
151
152
Future <void > createIsolate ([AppConnection ? appConnectionOverride]) async {
@@ -241,6 +242,7 @@ class WebSocketProxyService implements VmServiceInterface {
241
242
_isolateRef = null ;
242
243
_isolateRunning = false ;
243
244
_currentPauseEvent = null ;
245
+ _mainHasStarted = false ;
244
246
245
247
if (_initializedCompleter.isCompleted) {
246
248
_initializedCompleter = Completer <void >();
@@ -757,6 +759,26 @@ class WebSocketProxyService implements VmServiceInterface {
757
759
return UriList (uris: uris.map (DartUri .toResolvedUri).toList ());
758
760
}
759
761
762
+ /// Pauses execution of the isolate.
763
+ @override
764
+ Future <Success > pause (String isolateId) =>
765
+ wrapInErrorHandlerAsync ('pause' , () => _pause (isolateId));
766
+
767
+ Future <Success > _pause (String isolateId) async {
768
+ // Create a pause event and store it
769
+ if (_isolateRef != null ) {
770
+ final pauseEvent = vm_service.Event (
771
+ kind: vm_service.EventKind .kPauseInterrupted,
772
+ timestamp: DateTime .now ().millisecondsSinceEpoch,
773
+ isolate: _isolateRef! ,
774
+ );
775
+ _currentPauseEvent = pauseEvent;
776
+ _streamNotify (vm_service.EventStreams .kDebug, pauseEvent);
777
+ }
778
+
779
+ return Success ();
780
+ }
781
+
760
782
/// Resumes execution of the isolate.
761
783
@override
762
784
Future <Success > resume (String isolateId, {String ? step, int ? frameIndex}) =>
@@ -773,7 +795,18 @@ class WebSocketProxyService implements VmServiceInterface {
773
795
if (hasPendingRestart && ! _resumeAfterRestartEventsController.isClosed) {
774
796
_resumeAfterRestartEventsController.add (isolateId);
775
797
} else {
776
- appConnection.runMain ();
798
+ if (! _mainHasStarted) {
799
+ try {
800
+ appConnection.runMain ();
801
+ _mainHasStarted = true ;
802
+ } catch (e) {
803
+ if (e.toString ().contains ('Main has already started' )) {
804
+ _mainHasStarted = true ;
805
+ } else {
806
+ rethrow ;
807
+ }
808
+ }
809
+ }
777
810
}
778
811
779
812
// Clear pause state and send resume event to notify debugging tools
0 commit comments