[flutter_tools] wrap http send in async guard (#69972)
This commit is contained in:
@@ -175,16 +175,19 @@ class CrashReportSender {
|
||||
filename: _kStackTraceFilename,
|
||||
));
|
||||
|
||||
final http.StreamedResponse resp = await _client.send(req);
|
||||
// package:http may throw unhandled async exceptions into the Zone.
|
||||
await asyncGuard(() async {
|
||||
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}');
|
||||
}
|
||||
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';
|
||||
|
||||
Reference in New Issue
Block a user