Index: runtime/vm/service/vmservice.dart |
diff --git a/runtime/vm/service/vmservice.dart b/runtime/vm/service/vmservice.dart |
index a627ed740fe13fd62d80d9ec25cf4f0d217bdd8c..2a6bbc2879ac870eda2bee4e19bc7456426b069f 100644 |
--- a/runtime/vm/service/vmservice.dart |
+++ b/runtime/vm/service/vmservice.dart |
@@ -68,7 +68,9 @@ class VMService extends MessageRouter { |
void _exit() { |
isolateLifecyclePort.close(); |
scriptLoadPort.close(); |
- for (var client in clients) { |
+ // Create a copy of the set as a list because client.close() alters the set. |
+ var clientsList = clients.toList(); |
+ for (var client in clientsList) { |
client.close(); |
} |
// Call embedder shutdown hook after the internal shutdown. |