Skip to content

Crash: "Bad state: Future already completed" when hot restarting #74407

@DanTup

Description

@DanTup

Using current master version (5b0f69f), I reliably see a crash when trying to hot reload (on iOS Simulator). I can reproduce from the terminal and using a clean flutter create project.

  • Run flutter create foo && cd foo
  • Run flutter run (I'm using iOS Simulator, I'm unsure if that matters)
  • When the app loads, press Shift+R to hot restart
  • If it doesn't crash, press Shift+R again

It always seems to happen within 1 or 2 restarts for me.

command

flutter run --target lib/main.dart -d F3122E57-B9F0-4AAB-9C88-92EBE7B77289

exception

StateError: Bad state: Future already completed

#0      _AsyncCompleter.complete (dart:async/future_impl.dart:45:31)
#1      ResidentRunner.waitForExtension.<anonymous closure> (package:flutter_tools/src/resident_runner.dart:1425:19)
#2      _rootRunUnary (dart:async/zone.dart:1362:47)
#3      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#6      _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#7      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
#8      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
#9      _rootRun (dart:async/zone.dart:1346:47)
#10     _CustomZone.run (dart:async/zone.dart:1258:19)
#11     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#12     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
#13     _rootRun (dart:async/zone.dart:1354:13)
#14     _CustomZone.run (dart:async/zone.dart:1258:19)
#15     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#16     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
#17     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#18     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#19     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:120:13)
#20     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

flutter doctor

[✓] Flutter (Channel master, 1.26.0-2.0.pre.451, on macOS 11.1 20C69 darwin-x64, locale en-GB)
    • Flutter version 1.26.0-2.0.pre.451 at /Users/danny/Dev/Google/flutter
    • Framework revision 5b0f69f961 (2 hours ago), 2021-01-21 07:49:03 -0500
    • Engine revision 30bb7452f8
    • Dart version 2.12.0 (build 2.12.0-247.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/danny/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • 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 at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.1

[✓] Connected device (3 available)
    • iPhone 12 Pro Max (mobile) • F3122E57-B9F0-4AAB-9C88-92EBE7B77289 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • macOS 11.1 20C69 darwin-x64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 87.0.4280.141

• No issues found!

Metadata

Metadata

Assignees

Labels

a: tests"flutter test", flutter_test, or one of our teststoolAffects the "flutter" command-line tool. See also t: labels.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions