Skip to content

Commit

Permalink
grpc-js: Fix shutting down subchannels in separate pools
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Apr 20, 2022
1 parent fa92727 commit cf4c79f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/grpc-js/package.json
@@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "1.6.6",
"version": "1.6.7",
"description": "gRPC Library for Node - pure JS implementation",
"homepage": "https://grpc.io/",
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
Expand Down
14 changes: 5 additions & 9 deletions packages/grpc-js/src/subchannel-pool.ts
Expand Up @@ -49,10 +49,8 @@ export class SubchannelPool {
/**
* A pool of subchannels use for making connections. Subchannels with the
* exact same parameters will be reused.
* @param global If true, this is the global subchannel pool. Otherwise, it
* is the pool for a single channel.
*/
constructor(private global: boolean) {}
constructor() {}

/**
* Unrefs all unused subchannels and cancels the cleanup task if all
Expand Down Expand Up @@ -95,7 +93,7 @@ export class SubchannelPool {
* Ensures that the cleanup task is spawned.
*/
ensureCleanupTask(): void {
if (this.global && this.cleanupTimer === null) {
if (this.cleanupTimer === null) {
this.cleanupTimer = setInterval(() => {
this.unrefUnusedSubchannels();
}, REF_CHECK_INTERVAL);
Expand Down Expand Up @@ -156,14 +154,12 @@ export class SubchannelPool {
channelCredentials,
subchannel,
});
if (this.global) {
subchannel.ref();
}
subchannel.ref();
return subchannel;
}
}

const globalSubchannelPool = new SubchannelPool(true);
const globalSubchannelPool = new SubchannelPool();

/**
* Get either the global subchannel pool, or a new subchannel pool.
Expand All @@ -173,6 +169,6 @@ export function getSubchannelPool(global: boolean): SubchannelPool {
if (global) {
return globalSubchannelPool;
} else {
return new SubchannelPool(false);
return new SubchannelPool();
}
}

0 comments on commit cf4c79f

Please sign in to comment.