Unverified Commit c5d5463c authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tools] Fix hang in DesktopLogReader (#88178)

parent 325cfb0f
......@@ -314,15 +314,15 @@ class DesktopLogReader extends DeviceLogReader {
final StreamSubscription<List<int>> stderrSub = process.stderr.listen(
_inputController.add,
);
final Future<void> stdioFuture = Future.wait<void>(<Future<void>>[
stdoutSub.asFuture<void>(),
stderrSub.asFuture<void>(),
]);
process.exitCode.whenComplete(() async {
// Wait for output to be fully processed.
await Future.wait<void>(<Future<void>>[
stdoutSub.asFuture<void>(),
stderrSub.asFuture<void>(),
]);
// The streams as futures have already completed, so waiting for the
// potentially async stream cancellation to complete likely has no
// benefit.
await stdioFuture;
// The streams have already completed, so waiting for the stream
// cancellation to complete is not needed.
unawaited(stdoutSub.cancel());
unawaited(stderrSub.cancel());
await _inputController.close();
......
......@@ -289,17 +289,13 @@ void main() {
final FakeDesktopDevice device = setUpDesktopDevice(
processManager: processManager,
);
final Completer<void> testCompleter = Completer<void>();
final List<String> logOutput = <String>[];
device.getLogReader().logLines.listen((String line) {
logOutput.add(line);
}, onDone: () {
expect(logOutput, contains('Oops'));
testCompleter.complete();
});
unawaited(Future<void>(() {
exitCompleter.complete();
}));
// Start looking for 'Oops' in the stream before starting the app.
expect(device.getLogReader().logLines, emits('Oops'));
final FakeApplicationPackage package = FakeApplicationPackage();
await device.startApp(
package,
......@@ -309,7 +305,6 @@ void main() {
dartEntrypointArgs: <String>['arg1', 'arg2'],
),
);
await testCompleter.future;
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment