Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always listen to onFrameReceived #674

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/src/client/http2_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ class Http2ClientConnection implements connection.ClientConnection {
);
transport.onFrameReceived
.listen((_) => keepAliveManager?.onFrameReceived());
} else {
// Listen to the stream to not cause memory leaks.
transport.onFrameReceived.listen(null).cancel().ignore();
}
_connectionLifeTimer
..reset()
Expand Down
4 changes: 1 addition & 3 deletions test/client_tests/client_keepalive_manager_test.mocks.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Mocks generated by Mockito 5.4.1 from annotations
// Mocks generated by Mockito 5.4.2 from annotations
// in grpc/test/client_tests/client_keepalive_manager_test.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:mockito/mockito.dart' as _i1;

Expand Down
3 changes: 2 additions & 1 deletion test/src/client_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import 'package:test/test.dart';
import 'client_utils.mocks.dart';
import 'utils.dart';

@GenerateMocks([ClientTransportConnection, ClientTransportStream])
@GenerateNiceMocks(
[MockSpec<ClientTransportConnection>(), MockSpec<ClientTransportStream>()])
class FakeConnection extends Http2ClientConnection {
final ClientTransportConnection transport;

Expand Down
34 changes: 23 additions & 11 deletions test/src/client_utils.mocks.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Mocks generated by Mockito 5.4.1 from annotations
// Mocks generated by Mockito 5.4.2 from annotations
// in grpc/test/src/client_utils.dart.
// Do not manually edit this file.

// @dart=2.19

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;

Expand Down Expand Up @@ -48,14 +46,11 @@ class _FakeStreamSink_1<S> extends _i1.SmartFake implements _i3.StreamSink<S> {
/// See the documentation for Mockito's code generation for more information.
class MockClientTransportConnection extends _i1.Mock
implements _i2.ClientTransportConnection {
MockClientTransportConnection() {
_i1.throwOnMissingStub(this);
}

@override
bool get isOpen => (super.noSuchMethod(
Invocation.getter(#isOpen),
returnValue: false,
returnValueForMissingStub: false,
) as bool);
@override
set onActiveStateChanged(_i2.ActiveStateHandler? callback) =>
Expand All @@ -70,16 +65,19 @@ class MockClientTransportConnection extends _i1.Mock
_i3.Future<void> get onInitialPeerSettingsReceived => (super.noSuchMethod(
Invocation.getter(#onInitialPeerSettingsReceived),
returnValue: _i3.Future<void>.value(),
returnValueForMissingStub: _i3.Future<void>.value(),
) as _i3.Future<void>);
@override
_i3.Stream<int> get onPingReceived => (super.noSuchMethod(
Invocation.getter(#onPingReceived),
returnValue: _i3.Stream<int>.empty(),
returnValueForMissingStub: _i3.Stream<int>.empty(),
) as _i3.Stream<int>);
@override
_i3.Stream<void> get onFrameReceived => (super.noSuchMethod(
Invocation.getter(#onFrameReceived),
returnValue: _i3.Stream<void>.empty(),
returnValueForMissingStub: _i3.Stream<void>.empty(),
) as _i3.Stream<void>);
@override
_i2.ClientTransportStream makeRequest(
Expand All @@ -100,6 +98,14 @@ class MockClientTransportConnection extends _i1.Mock
{#endStream: endStream},
),
),
returnValueForMissingStub: _FakeClientTransportStream_0(
this,
Invocation.method(
#makeRequest,
[headers],
{#endStream: endStream},
),
),
) as _i2.ClientTransportStream);
@override
_i3.Future<dynamic> ping() => (super.noSuchMethod(
Expand All @@ -108,6 +114,7 @@ class MockClientTransportConnection extends _i1.Mock
[],
),
returnValue: _i3.Future<dynamic>.value(),
returnValueForMissingStub: _i3.Future<dynamic>.value(),
) as _i3.Future<dynamic>);
@override
_i3.Future<dynamic> finish() => (super.noSuchMethod(
Expand All @@ -116,6 +123,7 @@ class MockClientTransportConnection extends _i1.Mock
[],
),
returnValue: _i3.Future<dynamic>.value(),
returnValueForMissingStub: _i3.Future<dynamic>.value(),
) as _i3.Future<dynamic>);
@override
_i3.Future<dynamic> terminate([int? errorCode]) => (super.noSuchMethod(
Expand All @@ -124,6 +132,7 @@ class MockClientTransportConnection extends _i1.Mock
[errorCode],
),
returnValue: _i3.Future<dynamic>.value(),
returnValueForMissingStub: _i3.Future<dynamic>.value(),
) as _i3.Future<dynamic>);
}

Expand All @@ -132,24 +141,23 @@ class MockClientTransportConnection extends _i1.Mock
/// See the documentation for Mockito's code generation for more information.
class MockClientTransportStream extends _i1.Mock
implements _i2.ClientTransportStream {
MockClientTransportStream() {
_i1.throwOnMissingStub(this);
}

@override
_i3.Stream<_i2.TransportStreamPush> get peerPushes => (super.noSuchMethod(
Invocation.getter(#peerPushes),
returnValue: _i3.Stream<_i2.TransportStreamPush>.empty(),
returnValueForMissingStub: _i3.Stream<_i2.TransportStreamPush>.empty(),
) as _i3.Stream<_i2.TransportStreamPush>);
@override
int get id => (super.noSuchMethod(
Invocation.getter(#id),
returnValue: 0,
returnValueForMissingStub: 0,
) as int);
@override
_i3.Stream<_i2.StreamMessage> get incomingMessages => (super.noSuchMethod(
Invocation.getter(#incomingMessages),
returnValue: _i3.Stream<_i2.StreamMessage>.empty(),
returnValueForMissingStub: _i3.Stream<_i2.StreamMessage>.empty(),
) as _i3.Stream<_i2.StreamMessage>);
@override
_i3.StreamSink<_i2.StreamMessage> get outgoingMessages => (super.noSuchMethod(
Expand All @@ -158,6 +166,10 @@ class MockClientTransportStream extends _i1.Mock
this,
Invocation.getter(#outgoingMessages),
),
returnValueForMissingStub: _FakeStreamSink_1<_i2.StreamMessage>(
this,
Invocation.getter(#outgoingMessages),
),
) as _i3.StreamSink<_i2.StreamMessage>);
@override
set onTerminated(void Function(int?)? value) => super.noSuchMethod(
Expand Down
Loading