Skip to content

Commit 55087d2

Browse files
committed
grpc-js: Transition subchannel to TRANSIENT_FAILURE when the socket closes
1 parent c96e7cf commit 55087d2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/grpc-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grpc/grpc-js",
3-
"version": "1.5.6",
3+
"version": "1.5.7",
44
"description": "gRPC Library for Node - pure JS implementation",
55
"homepage": "https://grpc.io/",
66
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",

packages/grpc-js/src/subchannel.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,15 @@ export class Subchannel {
669669
switch (newState) {
670670
case ConnectivityState.READY:
671671
this.stopBackoff();
672-
this.session!.socket.once('close', () => {
673-
for (const listener of this.disconnectListeners) {
674-
listener();
672+
const session = this.session!;
673+
session.socket.once('close', () => {
674+
if (this.session === session) {
675+
this.transitionToState(
676+
[ConnectivityState.READY],
677+
ConnectivityState.TRANSIENT_FAILURE);
678+
for (const listener of this.disconnectListeners) {
679+
listener();
680+
}
675681
}
676682
});
677683
if (this.keepaliveWithoutCalls) {

0 commit comments

Comments
 (0)