Unverified Commit 553662d1 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Catch AppConnectionException from dwds (#43544)

parent be53209e
...@@ -234,15 +234,14 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -234,15 +234,14 @@ class ResidentWebRunner extends ResidentRunner {
throwToolExit( throwToolExit(
'Failed to establish connection with Chrome. Try running the application again.\n' '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'); '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) { } on SocketException catch (err) {
throwToolExit(err.toString()); 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 { } finally {
if (statusActive) { if (statusActive) {
buildStatus.stop(); buildStatus.stop();
......
...@@ -565,13 +565,13 @@ void main() { ...@@ -565,13 +565,13 @@ void main() {
await expectation; await expectation;
})); }));
test('Successfully turns AppInstanceId error into ToolExit', () => testbed.run(() async { test('Successfully turns AppConnectionException into ToolExit', () => testbed.run(() async {
_setupMocks(); _setupMocks();
final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>(); final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
final Completer<void> unhandledErrorCompleter = Completer<void>(); final Completer<void> unhandledErrorCompleter = Completer<void>();
when(mockWebFs.connect(any)).thenAnswer((Invocation _) async { when(mockWebFs.connect(any)).thenAnswer((Invocation _) async {
unawaited(unhandledErrorCompleter.future.then((void value) { 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); return ConnectionResult(mockAppConnection, mockDebugConnection);
}); });
......
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