From 98cd87f7512c95cd48bf04c3225f0fa22b5dcb78 Mon Sep 17 00:00:00 2001 From: David Fiala Date: Thu, 6 Jun 2024 22:57:13 -0700 Subject: [PATCH] ensure that client keepalive timers are always cleared when they trigger. this is a necessary change to fit with having removed keepaliveDisabled boolean. manually inspected test logs for both server.ts and transport.ts to verify both types of keepalives are operating correctly. --- packages/grpc-js/src/transport.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/grpc-js/src/transport.ts b/packages/grpc-js/src/transport.ts index ab543821..06509cb1 100644 --- a/packages/grpc-js/src/transport.ts +++ b/packages/grpc-js/src/transport.ts @@ -422,6 +422,7 @@ class Http2Transport implements Transport { 'Sending ping with timeout ' + this.keepaliveTimeoutMs + 'ms' ); this.keepaliveTimer = setTimeout(() => { + this.keepaliveTimer = null; this.keepaliveTrace('Ping timeout passed without response'); this.handleDisconnect(); }, this.keepaliveTimeoutMs); @@ -471,6 +472,7 @@ class Http2Transport implements Transport { 'Starting keepalive timer for ' + this.keepaliveTimeMs + 'ms' ); this.keepaliveTimer = setTimeout(() => { + this.keepaliveTimer = null; this.maybeSendPing(); }, this.keepaliveTimeMs); this.keepaliveTimer.unref?.();