@@ -33,6 +33,14 @@ export class DartDebugSession extends DebugSession {
3333 // We normally track the pid from Observatory to terminate the VM afterwards, but for Flutter Run it's
3434 // a remote PID and therefore doesn't make sense to try and terminate.
3535 protected allowTerminatingObservatoryVmPid = true ;
36+ // Normally we don't connect to the VM when running no noDebug mode, but for
37+ // Flutter, this means we can't call service extensions (for ex. toggling
38+ // debug modes) so we allow it to override this (and then we skip things
39+ // like breakpoints). We can't do it always, because some functionality
40+ // (such as running multiple test suites) will break by having multiple
41+ // potential VM services come and go.
42+ // https://github.com/Dart-Code/Dart-Code/issues/1673
43+ protected connectVmEvenForNoDebug = false ;
3644 protected processExited = false ;
3745 public observatory ?: ObservatoryConnection ;
3846 protected cwd ?: string ;
@@ -55,6 +63,10 @@ export class DartDebugSession extends DebugSession {
5563 protected logCategory = LogCategory . General ; // This isn't used as General, since both Flutter and FlutterWeb override it.
5664 // protected observatoryUriIsProbablyReconnectable = false;
5765
66+ protected get shouldConnectDebugger ( ) {
67+ return ! this . noDebug || this . connectVmEvenForNoDebug ;
68+ }
69+
5870 public constructor ( ) {
5971 super ( ) ;
6072
@@ -113,7 +125,7 @@ export class DartDebugSession extends DebugSession {
113125 process . stdout . setEncoding ( "utf8" ) ;
114126 process . stdout . on ( "data" , ( data ) => {
115127 let match : RegExpExecArray | null = null ;
116- if ( this . parseObservatoryUriFromStdOut && ! this . observatory ) {
128+ if ( this . shouldConnectDebugger && this . parseObservatoryUriFromStdOut && ! this . observatory ) {
117129 match = ObservatoryConnection . bannerRegex . exec ( data . toString ( ) ) ;
118130 }
119131 if ( match ) {
@@ -137,6 +149,9 @@ export class DartDebugSession extends DebugSession {
137149 this . logToUser ( `Exited (${ signal ? `${ signal } ` . toLowerCase ( ) : code } )\n` ) ;
138150 this . sendEvent ( new TerminatedEvent ( ) ) ;
139151 } ) ;
152+
153+ if ( ! this . shouldConnectDebugger )
154+ this . sendEvent ( new InitializedEvent ( ) ) ;
140155 }
141156
142157 protected async attachRequest ( response : DebugProtocol . AttachResponse , args : DartAttachRequestArguments ) : Promise < void > {
@@ -181,8 +196,10 @@ export class DartDebugSession extends DebugSession {
181196
182197 protected spawnProcess ( args : DartLaunchRequestArguments ) {
183198 let appArgs = [ ] ;
184- appArgs . push ( `--enable-vm-service=${ args . vmServicePort } ` ) ;
185- appArgs . push ( "--pause_isolates_on_start=true" ) ;
199+ if ( ! this . shouldConnectDebugger ) {
200+ appArgs . push ( `--enable-vm-service=${ args . vmServicePort } ` ) ;
201+ appArgs . push ( "--pause_isolates_on_start=true" ) ;
202+ }
186203 if ( args . enableAsserts !== false ) { // undefined = on
187204 appArgs . push ( "--enable-asserts" ) ;
188205 }
@@ -255,6 +272,9 @@ export class DartDebugSession extends DebugSession {
255272 vmServiceUri : browserFriendlyUri . toString ( ) ,
256273 } ) ) ;
257274
275+ if ( ! this . shouldConnectDebugger )
276+ return ;
277+
258278 return new Promise < void > ( ( resolve , reject ) => {
259279 this . log ( `Connecting to VM Service at ${ uri } ` ) ;
260280 this . observatory = new ObservatoryConnection ( uri ) ;
0 commit comments