mirror of https://github.com/grpc/grpc-node.git
grpc-js: Clean up call even if status throws an error
This commit is contained in:
parent
f08d3aefd0
commit
ddec63af20
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@grpc/grpc-js",
|
||||
"version": "1.1.3",
|
||||
"version": "1.1.4",
|
||||
"description": "gRPC Library for Node - pure JS implementation",
|
||||
"homepage": "https://grpc.io/",
|
||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||
|
|
|
@ -227,7 +227,15 @@ export class Http2CallStream implements Call {
|
|||
const filteredStatus = this.filterStack.receiveTrailers(
|
||||
this.finalStatus!
|
||||
);
|
||||
this.listener?.onReceiveStatus(filteredStatus);
|
||||
/* We delay the actual action of bubbling up the status to insulate the
|
||||
* cleanup code in this class from any errors that may be thrown in the
|
||||
* upper layers as a result of bubbling up the status. In particular,
|
||||
* if the status is not OK, the "error" event may be emitted
|
||||
* synchronously at the top level, which will result in a thrown error if
|
||||
* the user does not handle that event. */
|
||||
process.nextTick(() => {
|
||||
this.listener?.onReceiveStatus(filteredStatus);
|
||||
});
|
||||
if (this.subchannel) {
|
||||
this.subchannel.callUnref();
|
||||
this.subchannel.removeDisconnectListener(this.disconnectListener);
|
||||
|
@ -602,6 +610,7 @@ export class Http2CallStream implements Call {
|
|||
} else {
|
||||
code = http2.constants.NGHTTP2_CANCEL;
|
||||
}
|
||||
this.trace('close http2 stream with code ' + code);
|
||||
this.http2Stream.close(code);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,6 +373,12 @@ export class Http2ServerCallStream<
|
|||
});
|
||||
|
||||
this.stream.once('close', () => {
|
||||
trace(
|
||||
'Request to method ' +
|
||||
this.handler?.path +
|
||||
' stream closed with rstCode ' +
|
||||
this.stream.rstCode
|
||||
);
|
||||
this.cancelled = true;
|
||||
this.emit('cancelled', 'cancelled');
|
||||
});
|
||||
|
|
|
@ -543,11 +543,21 @@ export class Server {
|
|||
|
||||
try {
|
||||
const path = headers[http2.constants.HTTP2_HEADER_PATH] as string;
|
||||
const serverAddress = http2Server.address();
|
||||
let serverAddressString = 'null';
|
||||
if (serverAddress) {
|
||||
if (typeof serverAddress === 'string') {
|
||||
serverAddressString = serverAddress;
|
||||
} else {
|
||||
serverAddressString =
|
||||
serverAddress.address + ':' + serverAddress.port;
|
||||
}
|
||||
}
|
||||
trace(
|
||||
'Received call to method ' +
|
||||
path +
|
||||
' at address ' +
|
||||
http2Server.address()?.toString()
|
||||
serverAddressString
|
||||
);
|
||||
const handler = this.handlers.get(path);
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ export class Subchannel {
|
|||
);
|
||||
}
|
||||
trace(
|
||||
this.subchannelAddress +
|
||||
this.subchannelAddressString +
|
||||
' connection closed by GOAWAY with code ' +
|
||||
errorCode
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue