Catch AppConnectionException from dwds (#43544)

This commit is contained in:
Jonah Williams 2019-10-25 20:35:19 -07:00 committed by GitHub
parent be53209e82
commit 553662d101
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -234,15 +234,14 @@ class ResidentWebRunner extends ResidentRunner {
throwToolExit(
'Failed to establish connection with Chrome. Try running the application again.\n'
'If this problem persists, please file an issue with the details below:\n$err\n$stackTrace');
} on AppConnectionException {
throwToolExit(
'Failed to establish connection with the application instance in Chrome.\n'
'This can happen if the websocket connection used by the web tooling is '
'unabled to correctly establish a connection, for example due to a firewall.'
);
} on SocketException catch (err) {
throwToolExit(err.toString());
} on StateError catch (err) {
// Handle known state error.
final String message = err.toString();
if (message.contains('Could not connect to application with appInstanceId')) {
throwToolExit(message);
}
rethrow;
} finally {
if (statusActive) {
buildStatus.stop();

View file

@ -565,13 +565,13 @@ void main() {
await expectation;
}));
test('Successfully turns AppInstanceId error into ToolExit', () => testbed.run(() async {
test('Successfully turns AppConnectionException into ToolExit', () => testbed.run(() async {
_setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
final Completer<void> unhandledErrorCompleter = Completer<void>();
when(mockWebFs.connect(any)).thenAnswer((Invocation _) async {
unawaited(unhandledErrorCompleter.future.then((void value) {
throw StateError('Could not connect to application with appInstanceId: c0ae0750-ee91-11e9-cea6-35d95a968356');
throw AppConnectionException('Could not connect to application with appInstanceId: c0ae0750-ee91-11e9-cea6-35d95a968356');
}));
return ConnectionResult(mockAppConnection, mockDebugConnection);
});