[analysis_server] Listen for pub stdout/stderr before awaiting exitCode

On my Windows PC, the process never exits if we haven't subscribed to to the streams so this hands on awaiting exitCode (meaning the pub process never exits and the server never provides code completion for version numbers in pubspec.yaml).

Change-Id: I12a51d8fc50eee8c62d1ac1d4d51c9768a812ad8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/pub/pub_command.dart b/pkg/analysis_server/lib/src/services/pub/pub_command.dart
index 1c4e758..a92b47d 100644
--- a/pkg/analysis_server/lib/src/services/pub/pub_command.dart
+++ b/pkg/analysis_server/lib/src/services/pub/pub_command.dart
@@ -115,10 +115,13 @@
           environment: {_pubEnvironmentKey: _pubEnvironmentValue});
       _activeProcesses.add(process);
 
+      final stdoutFuture = process.stdout.transform(utf8.decoder).join();
+      final stderrFuture = process.stderr.transform(utf8.decoder).join();
       final exitCode = await process.exitCode;
       _activeProcesses.remove(process);
-      final stdout = await process.stdout.transform(utf8.decoder).join();
-      final stderr = await process.stderr.transform(utf8.decoder).join();
+
+      final stdout = await stdoutFuture;
+      final stderr = await stderrFuture;
 
       if (exitCode != 0) {
         _instrumentationService