grpc-js: Transition subchannel to TRANSIENT_FAILURE when the socket closes

This commit is contained in:
Michael Lumish 2022-02-24 09:09:54 -08:00
parent c96e7cfa2a
commit 55087d21c4
2 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@grpc/grpc-js",
"version": "1.5.6",
"version": "1.5.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",

View File

@ -669,9 +669,15 @@ export class Subchannel {
switch (newState) {
case ConnectivityState.READY:
this.stopBackoff();
this.session!.socket.once('close', () => {
for (const listener of this.disconnectListeners) {
listener();
const session = this.session!;
session.socket.once('close', () => {
if (this.session === session) {
this.transitionToState(
[ConnectivityState.READY],
ConnectivityState.TRANSIENT_FAILURE);
for (const listener of this.disconnectListeners) {
listener();
}
}
});
if (this.keepaliveWithoutCalls) {