Unverified Commit 1f210275 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] wrap http send in async guard (#69972)

parent 75e8428b
......@@ -175,16 +175,19 @@ class CrashReportSender {
filename: _kStackTraceFilename,
));
final http.StreamedResponse resp = await _client.send(req);
if (resp.statusCode == 200) {
final String reportId = await http.ByteStream(resp.stream)
.bytesToString();
_logger.printTrace('Crash report sent (report ID: $reportId)');
_crashReportSent = true;
} else {
_logger.printError('Failed to send crash report. Server responded with HTTP status code ${resp.statusCode}');
}
// package:http may throw unhandled async exceptions into the Zone.
await asyncGuard(() async {
final http.StreamedResponse resp = await _client.send(req);
if (resp.statusCode == HttpStatus.ok) {
final String reportId = await http.ByteStream(resp.stream)
.bytesToString();
_logger.printTrace('Crash report sent (report ID: $reportId)');
_crashReportSent = true;
} else {
_logger.printError('Failed to send crash report. Server responded with HTTP status code ${resp.statusCode}');
}
});
// Catch all exceptions to print the message that makes clear that the
// crash logger crashed.
} catch (sendError, sendStackTrace) { // ignore: avoid_catches_without_on_clauses
......
......@@ -12,6 +12,7 @@ import 'package:intl/intl.dart';
import 'package:meta/meta.dart';
import 'package:usage/usage_io.dart';
import '../base/async_guard.dart';
import '../base/error_handling_io.dart';
import '../base/file_system.dart';
import '../base/io.dart';
......
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