Skip to content

Commit 3c5ab22

Browse files
committed
per discussion, avoid tracking keepalive disabled state and instead depend on whether the session is destroyed
1 parent c2da436 commit 3c5ab22

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/grpc-js/src/transport.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ class Http2Transport implements Transport {
119119
* calls, and a ping should be sent the next time a call starts.
120120
*/
121121
private pendingSendKeepalivePing = false;
122-
/**
123-
* Indicates when keepalives should no longer be performed for this transport. Used to prevent a race where a
124-
* latent session.ping(..) callback is called after the transport has been notified to disconnect.
125-
*/
126-
private keepaliveDisabled = false;
127122

128123
private userAgent: string;
129124

@@ -387,7 +382,6 @@ class Http2Transport implements Transport {
387382
* Handle connection drops, but not GOAWAYs.
388383
*/
389384
private handleDisconnect() {
390-
this.keepaliveDisabled = true;
391385
this.clearKeepaliveTimeout();
392386
this.reportDisconnectToOwner(false);
393387
/* Give calls an event loop cycle to finish naturally before reporting the
@@ -396,6 +390,7 @@ class Http2Transport implements Transport {
396390
for (const call of this.activeCalls) {
397391
call.onDisconnect();
398392
}
393+
this.session.destroy();
399394
});
400395
}
401396

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

406401
private canSendPing() {
407402
return (
408-
!this.keepaliveDisabled &&
403+
!this.session.destroyed &&
409404
this.keepaliveTimeMs > 0 &&
410405
(this.keepaliveWithoutCalls || this.activeCalls.size > 0)
411406
);

0 commit comments

Comments
 (0)