Skip to content

Commit

Permalink
Merge pull request #2322 from murgatroid99/grpc-js_transport_session_ref
Browse files Browse the repository at this point in the history
grpc-js: Reference session in transport when there are active calls
  • Loading branch information
murgatroid99 committed Jan 12, 2023
2 parents 3db8acb + 7eaebaf commit a9f87fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/grpc-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "1.8.3",
"version": "1.8.4",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
Expand Down
4 changes: 3 additions & 1 deletion packages/grpc-js/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,14 @@ class Http2Transport implements Transport {
private removeActiveCall(call: Http2SubchannelCall) {
this.activeCalls.delete(call);
if (this.activeCalls.size === 0 && !this.keepaliveWithoutCalls) {
this.session.unref();
this.stopKeepalivePings();
}
}

private addActiveCall(call: Http2SubchannelCall) {
if (this.activeCalls.size === 0 && !this.keepaliveWithoutCalls) {
this.session.ref();
this.startKeepalivePings();
}
this.activeCalls.add(call);
Expand Down Expand Up @@ -418,14 +420,14 @@ class Http2Transport implements Transport {
},
onCallEnd: status => {
subchannelCallStatsTracker.onCallEnd?.(status);
this.removeActiveCall(call);
},
onStreamEnd: success => {
if (success) {
this.streamTracker.addCallSucceeded();
} else {
this.streamTracker.addCallFailed();
}
this.removeActiveCall(call);
subchannelCallStatsTracker.onStreamEnd?.(success);
}
}
Expand Down

0 comments on commit a9f87fc

Please sign in to comment.