Fix race condition in resident_runner (#21696)

* Don't set the `vmServices` member variable until it's fully initialized.
* Add a timeout to the future that sends the 'started' event to the IDE

https://github.com/flutter/flutter/issues/16604
This commit is contained in:
Todd Volkert
2018-09-11 20:58:47 -07:00
committed by GitHub
parent ed88478e23
commit d7a0dcaa4a
2 changed files with 9 additions and 3 deletions

View File

@@ -423,7 +423,12 @@ class AppDomain extends Domain {
final Completer<void> appStartedCompleter = new Completer<void>();
// We don't want to wait for this future to complete and callbacks won't fail.
// As it just writes to stdout.
appStartedCompleter.future.then<void>((_) { // ignore: unawaited_futures
appStartedCompleter.future.timeout(const Duration(minutes: 1), onTimeout: () { // ignore: unawaited_futures
_sendAppEvent(app, 'log', <String, dynamic>{
'log': 'timeout waiting for the application to start',
'error': true,
});
}).then<void>((_) {
_sendAppEvent(app, 'started');
});