Turn on unawaited_futures in flutter_tools (#21048)
This commit is contained in:
@@ -236,7 +236,11 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
|
||||
environment: androidSdk.sdkManagerEnv,
|
||||
);
|
||||
|
||||
process.stdin.addStream(stdin);
|
||||
// The real stdin will never finish streaming. Pipe until the child process
|
||||
// finishes.
|
||||
process.stdin.addStream(stdin); // ignore: unawaited_futures
|
||||
// Wait for stdout and stderr to be fully processed, because process.exitCode
|
||||
// may complete first.
|
||||
await waitGroup<void>(<Future<void>>[
|
||||
stdout.addStream(process.stdout),
|
||||
stderr.addStream(process.stderr),
|
||||
|
||||
@@ -191,7 +191,9 @@ Future<int> runInteractively(List<String> command, {
|
||||
allowReentrantFlutter: allowReentrantFlutter,
|
||||
environment: environment,
|
||||
);
|
||||
process.stdin.addStream(stdin);
|
||||
// The real stdin will never finish streaming. Pipe until the child process
|
||||
// finishes.
|
||||
process.stdin.addStream(stdin); // ignore: unawaited_futures
|
||||
// Wait for stdout and stderr to be fully processed, because process.exitCode
|
||||
// may complete first.
|
||||
await Future.wait<dynamic>(<Future<dynamic>>[
|
||||
|
||||
@@ -92,7 +92,8 @@ class AnalyzeOnce extends AnalyzeBase {
|
||||
});
|
||||
|
||||
await server.start();
|
||||
server.onExit.then((int exitCode) {
|
||||
// Completing the future in the callback can't fail.
|
||||
server.onExit.then((int exitCode) { // ignore: unawaited_futures
|
||||
if (!analysisCompleter.isCompleted) {
|
||||
analysisCompleter.completeError('analysis server exited: $exitCode');
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class AttachCommand extends FlutterCommand {
|
||||
|
||||
@override
|
||||
Future<Null> validateCommand() async {
|
||||
super.validateCommand();
|
||||
await super.validateCommand();
|
||||
if (await findTargetDevice() == null)
|
||||
throwToolExit(null);
|
||||
observatoryPort;
|
||||
|
||||
@@ -444,7 +444,8 @@ class _PortForwarder {
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen((String data) { printTrace(data); });
|
||||
process.exitCode.then((int c) {
|
||||
// Best effort to print the exit code.
|
||||
process.exitCode.then((int c) { // ignore: unawaited_futures
|
||||
printTrace("'${command.join(' ')}' exited with exit code $c");
|
||||
});
|
||||
printTrace('Set up forwarding from $localPort to $address:$remotePort');
|
||||
|
||||
@@ -45,8 +45,7 @@ class AnalysisServer {
|
||||
printTrace('dart ${command.skip(1).join(' ')}');
|
||||
_process = await processManager.start(command);
|
||||
// This callback hookup can't throw.
|
||||
_process.exitCode
|
||||
.whenComplete(() => _process = null); // ignore: unawaited_futures
|
||||
_process.exitCode.whenComplete(() => _process = null); // ignore: unawaited_futures
|
||||
|
||||
final Stream<String> errorStream =
|
||||
_process.stderr.transform(utf8.decoder).transform(const LineSplitter());
|
||||
|
||||
@@ -153,9 +153,7 @@ Future<Map<String, String>> getCodeSigningIdentityDevelopmentTeam({
|
||||
);
|
||||
|
||||
final Process opensslProcess = await runCommand(const <String>['openssl', 'x509', '-subject']);
|
||||
opensslProcess.stdin
|
||||
..write(signingCertificate)
|
||||
..close();
|
||||
await (opensslProcess.stdin..write(signingCertificate)).close();
|
||||
|
||||
final String opensslOutput = await utf8.decodeStream(opensslProcess.stdout);
|
||||
// Fire and forget discard of the stderr stream so we don't hold onto resources.
|
||||
|
||||
@@ -762,7 +762,7 @@ abstract class ResidentRunner {
|
||||
await handleTerminalCommand(command);
|
||||
} catch (error, st) {
|
||||
printError('$error\n$st');
|
||||
_cleanUpAndExit(null);
|
||||
await _cleanUpAndExit(null);
|
||||
} finally {
|
||||
_processingUserRequest = false;
|
||||
}
|
||||
|
||||
@@ -590,21 +590,28 @@ class HotRunner extends ResidentRunner {
|
||||
pause: pause
|
||||
);
|
||||
countExpectedReports += reports.length;
|
||||
Future.wait(reports).catchError((dynamic error) {
|
||||
return <Map<String, dynamic>>[error];
|
||||
}).then((List<Map<String, dynamic>> list) {
|
||||
// TODO(aam): Investigate why we are validating only first reload report,
|
||||
// which seems to be current behavior
|
||||
final Map<String, dynamic> firstReport = list.first;
|
||||
// Don't print errors because they will be printed further down when
|
||||
// `validateReloadReport` is called again.
|
||||
device.updateReloadStatus(validateReloadReport(firstReport,
|
||||
printErrors: false));
|
||||
if (!retrieveFirstReloadReport.isCompleted)
|
||||
retrieveFirstReloadReport.complete(firstReport);
|
||||
}, onError: (dynamic error, StackTrace stack) {
|
||||
retrieveFirstReloadReport.completeError(error, stack);
|
||||
});
|
||||
await Future
|
||||
.wait(reports)
|
||||
.catchError((dynamic error) {
|
||||
return <Map<String, dynamic>>[error];
|
||||
})
|
||||
.then(
|
||||
(List<Map<String, dynamic>> list) {
|
||||
// TODO(aam): Investigate why we are validating only first reload report,
|
||||
// which seems to be current behavior
|
||||
final Map<String, dynamic> firstReport = list.first;
|
||||
// Don't print errors because they will be printed further down when
|
||||
// `validateReloadReport` is called again.
|
||||
device.updateReloadStatus(
|
||||
validateReloadReport(firstReport, printErrors: false)
|
||||
);
|
||||
if (!retrieveFirstReloadReport.isCompleted)
|
||||
retrieveFirstReloadReport.complete(firstReport);
|
||||
},
|
||||
onError: (dynamic error, StackTrace stack) {
|
||||
retrieveFirstReloadReport.completeError(error, stack);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
if (countExpectedReports == 0) {
|
||||
|
||||
@@ -157,7 +157,8 @@ class FlutterTesterDevice extends Device {
|
||||
'FLUTTER_TEST': 'true',
|
||||
},
|
||||
);
|
||||
_process.exitCode.then((_) => _isRunning = false);
|
||||
// Setting a bool can't fail in the callback.
|
||||
_process.exitCode.then((_) => _isRunning = false); // ignore: unawaited_futures
|
||||
_process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
|
||||
Reference in New Issue
Block a user