From fa5066759d239f34c4cf20bf41a16ca9a5f47bf8 Mon Sep 17 00:00:00 2001 From: Michael Lumish Date: Wed, 23 Jun 2021 14:01:56 -0700 Subject: [PATCH] grpc-js: Unref timers for keepalive functionality --- packages/grpc-js/package.json | 2 +- packages/grpc-js/src/subchannel.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/grpc-js/package.json b/packages/grpc-js/package.json index f859a326..8acb8a14 100644 --- a/packages/grpc-js/package.json +++ b/packages/grpc-js/package.json @@ -1,6 +1,6 @@ { "name": "@grpc/grpc-js", - "version": "1.3.3", + "version": "1.3.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", diff --git a/packages/grpc-js/src/subchannel.ts b/packages/grpc-js/src/subchannel.ts index 7a68a1a2..8991ee3b 100644 --- a/packages/grpc-js/src/subchannel.ts +++ b/packages/grpc-js/src/subchannel.ts @@ -280,6 +280,7 @@ export class Subchannel { this.keepaliveTimeoutId = setTimeout(() => { this.transitionToState([ConnectivityState.READY], ConnectivityState.IDLE); }, this.keepaliveTimeoutMs); + this.keepaliveTimeoutId.unref?.(); this.session!.ping( (err: Error | null, duration: number, payload: Buffer) => { clearTimeout(this.keepaliveTimeoutId); @@ -291,6 +292,7 @@ export class Subchannel { this.keepaliveIntervalId = setInterval(() => { this.sendPing(); }, this.keepaliveTimeMs); + this.keepaliveIntervalId.unref?.() /* Don't send a ping immediately because whatever caused us to start * sending pings should also involve some network activity. */ }