Skip to content

Commit

Permalink
per discussion, avoid tracking keepalive disabled state and instead d…
Browse files Browse the repository at this point in the history
…epend on whether the session is destroyed
  • Loading branch information
davidfiala committed Jun 6, 2024
1 parent c2da436 commit 3c5ab22
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/grpc-js/src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ class Http2Transport implements Transport {
* calls, and a ping should be sent the next time a call starts.
*/
private pendingSendKeepalivePing = false;
/**
* Indicates when keepalives should no longer be performed for this transport. Used to prevent a race where a
* latent session.ping(..) callback is called after the transport has been notified to disconnect.
*/
private keepaliveDisabled = false;

private userAgent: string;

Expand Down Expand Up @@ -387,7 +382,6 @@ class Http2Transport implements Transport {
* Handle connection drops, but not GOAWAYs.
*/
private handleDisconnect() {
this.keepaliveDisabled = true;
this.clearKeepaliveTimeout();
this.reportDisconnectToOwner(false);
/* Give calls an event loop cycle to finish naturally before reporting the
Expand All @@ -396,6 +390,7 @@ class Http2Transport implements Transport {
for (const call of this.activeCalls) {
call.onDisconnect();
}
this.session.destroy();
});
}

Expand All @@ -405,7 +400,7 @@ class Http2Transport implements Transport {

private canSendPing() {
return (
!this.keepaliveDisabled &&
!this.session.destroyed &&
this.keepaliveTimeMs > 0 &&
(this.keepaliveWithoutCalls || this.activeCalls.size > 0)
);
Expand Down

0 comments on commit 3c5ab22

Please sign in to comment.