Revert "Not to fail pending requests, just reschedule it (#303)" (#366)

This reverts commit 9ed03b6b96.

This change prevents client from gracefully handling connection issues and instead just makes it infinitely trying to reconnect.

Closes #339
This commit is contained in:
Vyacheslav Egorov 2020-10-02 22:22:33 +02:00 committed by GitHub
parent a657916168
commit 831f5d8cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -264,8 +264,9 @@ class Http2ClientConnection implements connection.ClientConnection {
} }
// TODO(jakobr): Log error. // TODO(jakobr): Log error.
_cancelTimer(); _cancelTimer();
_pendingCalls.forEach((call) => _failCall(call, error));
_pendingCalls.clear();
_setState(ConnectionState.idle); _setState(ConnectionState.idle);
_connect();
} }
void _handleReconnect() { void _handleReconnect() {

View File

@ -368,6 +368,24 @@ void main() {
); );
} }
test('Connection errors are reported', () async {
final connectionStates = <ConnectionState>[];
harness.connection.connectionError = 'Connection error';
harness.connection.onStateChanged = (connection) {
final state = connection.state;
connectionStates.add(state);
};
final expectedException =
GrpcError.unavailable('Error connecting: Connection error');
await harness.expectThrows(
harness.client.unary(dummyValue), expectedException);
expect(
connectionStates, [ConnectionState.connecting, ConnectionState.idle]);
});
test('Connections time out if idle', () async { test('Connections time out if idle', () async {
final done = Completer(); final done = Completer();
final connectionStates = <ConnectionState>[]; final connectionStates = <ConnectionState>[];