Merge pull request #2052 from murgatroid99/grpc-js_socket_disconnect

grpc-js: Transition subchannel to TRANSIENT_FAILURE when the socket closes
This commit is contained in:
Michael Lumish 2022-02-24 11:00:51 -08:00 committed by GitHub
commit fc686e3234
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {