mirror of https://github.com/grpc/grpc-node.git
proto-loader: Make serializers reject arrays
This commit is contained in:
parent
95290ae243
commit
144c41b366
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@grpc/proto-loader",
|
||||
"version": "0.6.5",
|
||||
"version": "0.6.6",
|
||||
"author": "Google Inc.",
|
||||
"contributors": [
|
||||
{
|
||||
|
|
|
@ -212,6 +212,9 @@ function createDeserializer(
|
|||
|
||||
function createSerializer(cls: Protobuf.Type): Serialize<object> {
|
||||
return function serialize(arg: object): Buffer {
|
||||
if (Array.isArray(arg)) {
|
||||
throw new Error(`Failed to serialize message: expected object with ${cls.name} structure, got array instead`);
|
||||
}
|
||||
const message = cls.fromObject(arg);
|
||||
return cls.encode(message).finish() as Buffer;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue