[flutter_tools] remove handling of error that is fixed (#58557)
The linked error has been fixed, removed work around. Updates the test cases to only test for exit instead of error message
#33050
diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart
index b7ced11..a152298 100644
--- a/packages/flutter_tools/lib/src/resident_runner.dart
+++ b/packages/flutter_tools/lib/src/resident_runner.dart
@@ -648,23 +648,6 @@
}
}
-// Issue: https://github.com/flutter/flutter/issues/33050
-// Matches the following patterns:
-// HttpException: Connection closed before full header was received, uri = *
-// HttpException: , uri = *
-final RegExp kAndroidQHttpConnectionClosedExp = RegExp(r'^HttpException\:.+\, uri \=.+$');
-
-/// Returns `true` if any of the devices is running Android Q.
-Future<bool> hasDeviceRunningAndroidQ(List<FlutterDevice> flutterDevices) async {
- for (final FlutterDevice flutterDevice in flutterDevices) {
- final String sdkNameAndVersion = await flutterDevice.device.sdkNameAndVersion;
- if (sdkNameAndVersion != null && sdkNameAndVersion.startsWith('Android 10')) {
- return true;
- }
- }
- return false;
-}
-
// Shared code between different resident application runners.
abstract class ResidentRunner {
ResidentRunner(
diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart
index 81d7fb9..d2da2b9 100644
--- a/packages/flutter_tools/lib/src/run_cold.dart
+++ b/packages/flutter_tools/lib/src/run_cold.dart
@@ -134,13 +134,6 @@
);
} on Exception catch (error) {
globals.printError('Error connecting to the service protocol: $error');
- // https://github.com/flutter/flutter/issues/33050
- // TODO(blasten): Remove this check once https://issuetracker.google.com/issues/132325318 has been fixed.
- if (await hasDeviceRunningAndroidQ(flutterDevices) &&
- error.toString().contains(kAndroidQHttpConnectionClosedExp)) {
- globals.printStatus('🔨 If you are using an emulator running Android Q Beta, consider using an emulator running API level 29 or lower.');
- globals.printStatus('Learn more about the status of this issue on https://issuetracker.google.com/issues/132325318');
- }
return 2;
}
for (final FlutterDevice device in flutterDevices) {
diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart
index 8b1d768..4150ddf 100644
--- a/packages/flutter_tools/lib/src/run_hot.dart
+++ b/packages/flutter_tools/lib/src/run_hot.dart
@@ -233,20 +233,6 @@
rethrow;
}
globals.printError('Error connecting to the service protocol: $error');
- // https://github.com/flutter/flutter/issues/33050
- // TODO(blasten): Remove this check once
- // https://issuetracker.google.com/issues/132325318 has been fixed.
- if (await hasDeviceRunningAndroidQ(flutterDevices) &&
- error.toString().contains(kAndroidQHttpConnectionClosedExp)) {
- globals.printStatus(
- '🔨 If you are using an emulator running Android Q Beta, '
- 'consider using an emulator running API level 29 or lower.',
- );
- globals.printStatus(
- 'Learn more about the status of this issue on '
- 'https://issuetracker.google.com/issues/132325318.',
- );
- }
return 2;
}
diff --git a/packages/flutter_tools/test/general.shard/cold_test.dart b/packages/flutter_tools/test/general.shard/cold_test.dart
index c7e9b28..83b3d74 100644
--- a/packages/flutter_tools/test/general.shard/cold_test.dart
+++ b/packages/flutter_tools/test/general.shard/cold_test.dart
@@ -6,9 +6,6 @@
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
-import 'package:flutter_tools/src/base/logger.dart';
-import 'package:flutter_tools/src/base/platform.dart';
-import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/device.dart';
@@ -23,75 +20,28 @@
import '../src/mocks.dart';
void main() {
- group('cold attach', () {
- MockResidentCompiler residentCompiler;
- BufferLogger mockLogger;
+ testUsingContext('Exits with code 2 when when HttpException is thrown '
+ 'during VM service connection', () async {
+ final MockResidentCompiler residentCompiler = MockResidentCompiler();
+ final MockDevice mockDevice = MockDevice();
+ when(mockDevice.supportsHotReload).thenReturn(true);
+ when(mockDevice.supportsHotRestart).thenReturn(false);
+ when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
+ when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10');
- setUp(() {
- mockLogger = BufferLogger(
- terminal: AnsiTerminal(
- stdio: null,
- platform: const LocalPlatform(),
- ),
- outputPreferences: OutputPreferences.test(),
- );
- residentCompiler = MockResidentCompiler();
- });
+ final List<FlutterDevice> devices = <FlutterDevice>[
+ TestFlutterDevice(
+ device: mockDevice,
+ generator: residentCompiler,
+ exception: const HttpException('Connection closed before full header was received, '
+ 'uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
+ ),
+ ];
- testUsingContext('Prints message when HttpException is thrown - 1', () async {
- final MockDevice mockDevice = MockDevice();
- when(mockDevice.supportsHotReload).thenReturn(true);
- when(mockDevice.supportsHotRestart).thenReturn(false);
- when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
- when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10');
-
- final List<FlutterDevice> devices = <FlutterDevice>[
- TestFlutterDevice(
- device: mockDevice,
- generator: residentCompiler,
- exception: const HttpException('Connection closed before full header was received, '
- 'uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
- ),
- ];
-
- final int exitCode = await ColdRunner(devices,
- debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
- ).attach();
- expect(exitCode, 2);
- expect(mockLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
- 'consider using an emulator running API level 29 or lower.'));
- expect(mockLogger.statusText, contains('Learn more about the status of this issue on '
- 'https://issuetracker.google.com/issues/132325318'));
- }, overrides: <Type, Generator>{
- Logger: () => mockLogger,
- });
-
- testUsingContext('Prints message when HttpException is thrown - 2', () async {
- final MockDevice mockDevice = MockDevice();
- when(mockDevice.supportsHotReload).thenReturn(true);
- when(mockDevice.supportsHotRestart).thenReturn(false);
- when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
- when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10');
-
- final List<FlutterDevice> devices = <FlutterDevice>[
- TestFlutterDevice(
- device: mockDevice,
- generator: residentCompiler,
- exception: const HttpException(', uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
- ),
- ];
-
- final int exitCode = await ColdRunner(devices,
- debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
- ).attach();
- expect(exitCode, 2);
- expect(mockLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
- 'consider using an emulator running API level 29 or lower.'));
- expect(mockLogger.statusText, contains('Learn more about the status of this issue on '
- 'https://issuetracker.google.com/issues/132325318'));
- }, overrides: <Type, Generator>{
- Logger: () => mockLogger,
- });
+ final int exitCode = await ColdRunner(devices,
+ debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
+ ).attach();
+ expect(exitCode, 2);
});
group('cleanupAtFinish()', () {
diff --git a/packages/flutter_tools/test/general.shard/hot_test.dart b/packages/flutter_tools/test/general.shard/hot_test.dart
index 0990943..48de79b 100644
--- a/packages/flutter_tools/test/general.shard/hot_test.dart
+++ b/packages/flutter_tools/test/general.shard/hot_test.dart
@@ -415,15 +415,15 @@
});
group('hot attach', () {
- MockResidentCompiler residentCompiler = MockResidentCompiler();
MockLocalEngineArtifacts mockArtifacts;
setUp(() {
- residentCompiler = MockResidentCompiler();
mockArtifacts = MockLocalEngineArtifacts();
});
- testUsingContext('Prints message when HttpException is thrown - 1', () async {
+ testUsingContext('Exits with code 2 when when HttpException is thrown '
+ 'during VM service connection', () async {
+ final MockResidentCompiler residentCompiler = MockResidentCompiler();
final MockDevice mockDevice = MockDevice();
when(mockDevice.supportsHotReload).thenReturn(true);
when(mockDevice.supportsHotRestart).thenReturn(false);
@@ -443,38 +443,6 @@
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
).attach();
expect(exitCode, 2);
- expect(testLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
- 'consider using an emulator running API level 29 or lower.'));
- expect(testLogger.statusText, contains('Learn more about the status of this issue on '
- 'https://issuetracker.google.com/issues/132325318'));
- }, overrides: <Type, Generator>{
- Artifacts: () => mockArtifacts,
- HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),
- });
-
- testUsingContext('Prints message when HttpException is thrown - 2', () async {
- final MockDevice mockDevice = MockDevice();
- when(mockDevice.supportsHotReload).thenReturn(true);
- when(mockDevice.supportsHotRestart).thenReturn(false);
- when(mockDevice.targetPlatform).thenAnswer((Invocation _) async => TargetPlatform.tester);
- when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation _) async => 'Android 10');
-
- final List<FlutterDevice> devices = <FlutterDevice>[
- TestFlutterDevice(
- device: mockDevice,
- generator: residentCompiler,
- exception: const HttpException(', uri = http://127.0.0.1:63394/5ZmLv8A59xY=/ws'),
- ),
- ];
-
- final int exitCode = await HotRunner(devices,
- debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
- ).attach();
- expect(exitCode, 2);
- expect(testLogger.statusText, contains('If you are using an emulator running Android Q Beta, '
- 'consider using an emulator running API level 29 or lower.'));
- expect(testLogger.statusText, contains('Learn more about the status of this issue on '
- 'https://issuetracker.google.com/issues/132325318'));
}, overrides: <Type, Generator>{
Artifacts: () => mockArtifacts,
HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true),