mirror of https://github.com/grpc/grpc-node.git
Check stream.session.socket before adding event handler
This commit is contained in:
parent
4b4addf5b9
commit
ae33497656
|
|
@ -342,6 +342,11 @@ export class Http2CallStream extends Duplex implements Call {
|
||||||
* from bubbling up. However, errors here should all correspond to
|
* from bubbling up. However, errors here should all correspond to
|
||||||
* "close" events, where we will handle the error more granularly */
|
* "close" events, where we will handle the error more granularly */
|
||||||
});
|
});
|
||||||
|
/* For some reason, stream.session.socket can sometimes be undefined.
|
||||||
|
* When that happens trying to add this event handler throws an error.
|
||||||
|
* This check is a stopgap measure to get this working sometimes until
|
||||||
|
* we understand/eliminate those cases. */
|
||||||
|
if (stream.session.socket) {
|
||||||
/* If the underlying TLS or TCP connection closes, we want to end the
|
/* If the underlying TLS or TCP connection closes, we want to end the
|
||||||
* call with an UNAVAILABLE status to match the behavior of the other
|
* call with an UNAVAILABLE status to match the behavior of the other
|
||||||
* library. In this handler we don't wait for trailers before ending the
|
* library. In this handler we don't wait for trailers before ending the
|
||||||
|
|
@ -350,6 +355,7 @@ export class Http2CallStream extends Duplex implements Call {
|
||||||
stream.session.socket.on('close', () => {
|
stream.session.socket.on('close', () => {
|
||||||
this.endCall({code: Status.UNAVAILABLE, details: 'Connection dropped', metadata: new Metadata()});
|
this.endCall({code: Status.UNAVAILABLE, details: 'Connection dropped', metadata: new Metadata()});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
if (!this.pendingRead) {
|
if (!this.pendingRead) {
|
||||||
stream.pause();
|
stream.pause();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue