Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc-js: Fix shutting down subchannels in separate pools #2103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
}
}
2 changes: 1 addition & 1 deletion packages/grpc-js/src/subchannel.ts
Expand Up @@ -741,7 +741,7 @@ export class Subchannel {
}
this.transitionToState(
[ConnectivityState.CONNECTING, ConnectivityState.READY],
ConnectivityState.TRANSIENT_FAILURE
ConnectivityState.IDLE
);
if (this.channelzEnabled) {
unregisterChannelzRef(this.channelzRef);
Expand Down