[flutter_tools] prevent StateError when log reader is disposed (#52173) Previously the AdbLogReader did async setup in the StreamController.onListen callback, specifically it would query the api version and start the adb process. If the log subscription was cancelled before this setup completed, then the log output could (haven't confirmed) get added to a closed controller, causing the above state error.
diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart index 49387c1..1779426 100644 --- a/packages/flutter_tools/lib/src/run_cold.dart +++ b/packages/flutter_tools/lib/src/run_cold.dart
@@ -94,7 +94,7 @@ if (device.vmService == null) { continue; } - device.initLogReader(); + await device.initLogReader(); await device.refreshViews(); globals.printTrace('Connected to ${device.device.name}'); } @@ -143,7 +143,7 @@ return 2; } for (final FlutterDevice device in flutterDevices) { - device.initLogReader(); + await device.initLogReader(); } await refreshViews(); for (final FlutterDevice device in flutterDevices) {