grpc-js: Move call to user code out of try block

This commit is contained in:
Michael Lumish 2021-01-25 13:24:39 -08:00
parent c328ba788d
commit 5ac9a1c2b6
2 changed files with 5 additions and 3 deletions

View File

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

@ -347,10 +347,11 @@ class BaseInterceptingCall implements InterceptingCallInterface {
let serialized: Buffer;
try {
serialized = this.methodDefinition.requestSerialize(message);
this.call.sendMessageWithContext(context, serialized);
} catch (e) {
this.call.cancelWithStatus(Status.INTERNAL, `Request message serialization failure: ${e.message}`);
return;
}
this.call.sendMessageWithContext(context, serialized);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessage(message: any) {
@ -370,7 +371,6 @@ class BaseInterceptingCall implements InterceptingCallInterface {
let deserialized: any;
try {
deserialized = this.methodDefinition.responseDeserialize(message);
interceptingListener?.onReceiveMessage?.(deserialized);
} catch (e) {
readError = {
code: Status.INTERNAL,
@ -378,7 +378,9 @@ class BaseInterceptingCall implements InterceptingCallInterface {
metadata: new Metadata(),
};
this.call.cancelWithStatus(readError.code, readError.details);
return;
}
interceptingListener?.onReceiveMessage?.(deserialized);
},
onReceiveStatus: (status) => {
if (readError) {