File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -373,6 +373,12 @@ class Server {
373
373
}
374
374
await new Future <Null >.delayed (const Duration (seconds: 1 ));
375
375
}
376
+ if (_service.isExiting) {
377
+ serverPrint ('Observatory HTTP server exiting before listening as '
378
+ 'vm service has received exit request\n ' );
379
+ await shutdown (true );
380
+ return this ;
381
+ }
376
382
_server.listen (_requestHandler, cancelOnError: true );
377
383
serverPrint ('Observatory listening on $serverAddress ' );
378
384
if (Platform .isFuchsia) {
Original file line number Diff line number Diff line change @@ -204,6 +204,9 @@ class VMService extends MessageRouter {
204
204
/// Collection of currently running isolates.
205
205
RunningIsolates runningIsolates = new RunningIsolates ();
206
206
207
+ /// Flag to indicate VM service is exiting.
208
+ bool isExiting = false ;
209
+
207
210
/// A port used to receive events from the VM.
208
211
final RawReceivePort eventPort;
209
212
@@ -323,6 +326,8 @@ class VMService extends MessageRouter {
323
326
}
324
327
325
328
Future _exit () async {
329
+ isExiting = true ;
330
+
326
331
// Stop the server.
327
332
if (VMServiceEmbedderHooks .serverStop != null ) {
328
333
await VMServiceEmbedderHooks .serverStop ();
@@ -342,6 +347,7 @@ class VMService extends MessageRouter {
342
347
if (VMServiceEmbedderHooks .cleanup != null ) {
343
348
await VMServiceEmbedderHooks .cleanup ();
344
349
}
350
+
345
351
// Notify the VM that we have exited.
346
352
_onExit ();
347
353
}
You can’t perform that action at this time.
0 commit comments