handle any RPCError
due to vm service disconnection in flutter run
(#156346)
Follow-up to https://github.com/flutter/flutter/pull/153714. While reading through run.dart, I noticed we missed a case.
This commit is contained in:
parent
9583cc1267
commit
e96c47f953
@ -856,7 +856,8 @@ class RunCommand extends RunCommandBase {
|
||||
throwToolExit(null, exitCode: result);
|
||||
}
|
||||
} on RPCError catch (error) {
|
||||
if (error.code == RPCErrorCodes.kServiceDisappeared) {
|
||||
if (error.code == RPCErrorCodes.kServiceDisappeared ||
|
||||
error.message.contains('Service connection disposed')) {
|
||||
throwToolExit('Lost connection to device.');
|
||||
}
|
||||
rethrow;
|
||||
|
@ -1096,9 +1096,13 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testUsingContext('Flutter run catches service has disappear errors and throws a tool exit', () async {
|
||||
testUsingContext('Flutter run catches catches errors due to vm service disconnection and throws a tool exit', () async {
|
||||
final FakeResidentRunner residentRunner = FakeResidentRunner();
|
||||
residentRunner.rpcError = RPCError('flutter._listViews', RPCErrorCodes.kServiceDisappeared, '');
|
||||
residentRunner.rpcError = RPCError(
|
||||
'flutter._listViews',
|
||||
RPCErrorCodes.kServiceDisappeared,
|
||||
'',
|
||||
);
|
||||
final TestRunCommandWithFakeResidentRunner command = TestRunCommandWithFakeResidentRunner();
|
||||
command.fakeResidentRunner = residentRunner;
|
||||
|
||||
@ -1106,6 +1110,17 @@ void main() {
|
||||
'run',
|
||||
'--no-pub',
|
||||
]), contains('Lost connection to device.'));
|
||||
|
||||
residentRunner.rpcError = RPCError(
|
||||
'flutter._listViews',
|
||||
RPCErrorCodes.kServerError,
|
||||
'Service connection disposed.',
|
||||
);
|
||||
|
||||
await expectToolExitLater(createTestCommandRunner(command).run(<String>[
|
||||
'run',
|
||||
'--no-pub',
|
||||
]), contains('Lost connection to device.'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Cache: () => Cache.test(processManager: FakeProcessManager.any()),
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user