grpc-js: Unref timers for keepalive functionality

This commit is contained in:
Michael Lumish 2021-06-23 14:01:56 -07:00
parent db3bf70e21
commit fa5066759d
2 changed files with 3 additions and 1 deletions

View File

@ -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",

View File

@ -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. */
}