mirror of https://github.com/grpc/grpc-node.git
fix: add addition check if the provided code is valid gRPC code
This commit is contained in:
parent
5e42be1b34
commit
aaee068a69
|
@ -739,15 +739,24 @@ export class Http2ServerCallStream<
|
|||
} else {
|
||||
this.messagesToPush.push(deserialized);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
// Ignore any remaining messages when errors occur.
|
||||
this.bufferedMessages.length = 0;
|
||||
|
||||
if(!err.code){
|
||||
err.code = Status.INTERNAL;
|
||||
if (
|
||||
!(
|
||||
'code' in error &&
|
||||
typeof error.code === 'number' &&
|
||||
Number.isInteger(error.code) &&
|
||||
error.code >= Status.OK &&
|
||||
error.code <= Status.UNAUTHENTICATED
|
||||
)
|
||||
) {
|
||||
// The error code is not a valid gRPC code so its being overwritten.
|
||||
error.code = Status.INTERNAL;
|
||||
}
|
||||
|
||||
readable.emit('error', err);
|
||||
|
||||
readable.emit('error', error);
|
||||
}
|
||||
|
||||
this.isPushPending = false;
|
||||
|
|
Loading…
Reference in New Issue