[ DevTools Server ] Add logging to server_connection_api_test

Will hopefully help resolve https://github.com/dart-lang/sdk/issues/52584

Change-Id: I9142c73cc24be070de6751e6f94f52e2605324fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454101
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jessy Yameogo <yjessy@google.com>
diff --git a/pkg/dds/test/devtools_server/server_connection_common.dart b/pkg/dds/test/devtools_server/server_connection_common.dart
index f812e9a..a7a7da2 100644
--- a/pkg/dds/test/devtools_server/server_connection_common.dart
+++ b/pkg/dds/test/devtools_server/server_connection_common.dart
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+import 'dart:convert';
+
 import 'package:devtools_shared/devtools_test_utils.dart';
 import 'package:test/test.dart';
 
@@ -83,19 +85,35 @@
       final devToolsUri =
           'http://${event['params']['host']}:${event['params']['port']}';
       final chrome = await Chrome.locate()!.start(url: devToolsUri);
+      final stdoutSub =
+          chrome.process.stdout.transform(utf8.decoder).listen((e) {
+        print('[CHROME STDOUT]: $e');
+      });
+      final stderrSub =
+          chrome.process.stderr.transform(utf8.decoder).listen((e) {
+        print('[CHROME STDERR]: $e');
+      });
 
       // Wait for DevTools to inform server that it's connected.
+      print('Waiting for clients...');
       await testController.waitForClients();
 
       // Close the browser, which will disconnect DevTools SSE connection
       // back to the server.
+      print('Killing Chrome...');
       chrome.kill();
+      await chrome.onExit;
+      await Future.wait([stdoutSub.cancel(), stderrSub.cancel()]);
 
       // Await a long delay to wait for the SSE client to close.
+      print('Delaying to wait for SSE connection to cleanup...');
       await delay(duration: const Duration(seconds: 15));
 
       // Ensure the client is completely removed from the list.
+      print('Expecting no clients...');
       await testController.waitForClients(expectNone: true);
+
+      print('Done!');
     }, timeout: const Timeout.factor(20));
   });
 }