Merge pull request #2322 from murgatroid99/grpc-js_transport_session_ref

grpc-js: Reference session in transport when there are active calls
This commit is contained in:
Michael Lumish 2023-01-12 11:04:50 -08:00 committed by GitHub
commit a9f87fcc3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@grpc/grpc-js", "name": "@grpc/grpc-js",
"version": "1.8.3", "version": "1.8.4",
"description": "gRPC Library for Node - pure JS implementation", "description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/", "homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", "repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

View File

@ -354,12 +354,14 @@ class Http2Transport implements Transport {
private removeActiveCall(call: Http2SubchannelCall) { private removeActiveCall(call: Http2SubchannelCall) {
this.activeCalls.delete(call); this.activeCalls.delete(call);
if (this.activeCalls.size === 0 && !this.keepaliveWithoutCalls) { if (this.activeCalls.size === 0 && !this.keepaliveWithoutCalls) {
this.session.unref();
this.stopKeepalivePings(); this.stopKeepalivePings();
} }
} }
private addActiveCall(call: Http2SubchannelCall) { private addActiveCall(call: Http2SubchannelCall) {
if (this.activeCalls.size === 0 && !this.keepaliveWithoutCalls) { if (this.activeCalls.size === 0 && !this.keepaliveWithoutCalls) {
this.session.ref();
this.startKeepalivePings(); this.startKeepalivePings();
} }
this.activeCalls.add(call); this.activeCalls.add(call);
@ -418,6 +420,7 @@ class Http2Transport implements Transport {
}, },
onCallEnd: status => { onCallEnd: status => {
subchannelCallStatsTracker.onCallEnd?.(status); subchannelCallStatsTracker.onCallEnd?.(status);
this.removeActiveCall(call);
}, },
onStreamEnd: success => { onStreamEnd: success => {
if (success) { if (success) {
@ -425,7 +428,6 @@ class Http2Transport implements Transport {
} else { } else {
this.streamTracker.addCallFailed(); this.streamTracker.addCallFailed();
} }
this.removeActiveCall(call);
subchannelCallStatsTracker.onStreamEnd?.(success); subchannelCallStatsTracker.onStreamEnd?.(success);
} }
} }