Repository: flutter
Issue: [tool_crash] StateError: Bad state: Future already completed
Labels: c: crash,tool,P2,team-tool,triaged-tool

Flutter crash report.
Please report a bug at https://github.com/flutter/flutter/issues.

## command

flutter --no-color attach --machine --device-id=443491a lib/main.dart

## exception

StateError: Bad state: Future already completed

```
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:43:31)
#1      FlutterDevice.connect.<anonymous closure> (package:flutter_tools/src/resident_runner.dart:251:17)
<asynchronous suspension>
#2      FlutterDevice.connect.<anonymous closure> (package:flutter_tools/src/resident_runner.dart)
#3      _rootRunUnary (dart:async/zone.dart:1198:47)
#4      _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#5      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#6      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
#7      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
#8      _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:385:25)
#9      _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:250:5)
#10     Stream.asyncMap.<anonymous closure>.add (dart:async/stream.dart:580:20)
#11     _rootRunUnary (dart:async/zone.dart:1198:47)
#12     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#13     _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#14     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#15     Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#16     Future._completeWithValue (dart:async/future_impl.dart:529:5)
#17     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#18     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#19     ProtocolDiscovery._forwardPort (package:flutter_tools/src/protocol_discovery.dart)
<asynchronous suspension>
#20     Stream.asyncMap.<anonymous closure>.<anonymous closure> (dart:async/stream.dart:588:29)
#21     _rootRunUnary (dart:async/zone.dart:1198:47)
#22     _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#23     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
#24     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
#25     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
#26     _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:69:11)
#27     _EventSinkWrapper.add (dart:async/stream_transformers.dart:15:11)
#28     _throttle.<anonymous closure>.<anonymous closure> (package:flutter_tools/src/protocol_discovery.dart:239:18)
#29     _rootRun (dart:async/zone.dart:1182:47)
#30     _CustomZone.run (dart:async/zone.dart:1093:19)
#31     _FutureListener.handleWhenComplete (dart:async/future_impl.dart:167:18)
#32     Future._propagateToListeners.handleWhenCompleteCallback (dart:async/future_impl.dart:666:39)
#33     Future._propagateToListeners (dart:async/future_impl.dart:722:37)
#34     Future._complete (dart:async/future_impl.dart:519:7)
#35     new Future.delayed.<anonymous closure> (dart:async/future.dart:323:16)
#36     _rootRun (dart:async/zone.dart:1182:47)
#37     _CustomZone.run (dart:async/zone.dart:1093:19)
#38     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
#39     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
#40     _rootRun (dart:async/zone.dart:1190:13)
#41     _CustomZone.run (dart:async/zone.dart:1093:19)
#42     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
#43     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:18:15)
#44     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:397:19)
#45     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:428:5)
#46     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
```

## flutter doctor

```
[✓] Flutter (Channel unknown, 1.22.2+bigo.3.1, on Mac OS X 10.14.6 18G103, locale zh-Hans-CN)
    • Flutter version 1.22.2+bigo.3.1 at /Users/abccool/.terra/caches/sdk/v1.22.2-bigo.3.1/flutter
    • Framework revision d10db9632e (4 weeks ago), 2021-02-09 14:10:09 +0800
    • Engine revision b8752bbfff
    • Dart version 2.10.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/abccool/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install:
        sudo gem install cocoapods

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.53.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.19.0

[✓] Connected device (1 available)
    • Redmi Note 7 (mobile) • 443491a • android-arm64 • Android 9 (API 28)

! Doctor found issues in 2 categories.
```