diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc index b08a9f96d8120624b6f9df4197f99a58420af045..f98fe2463b694f77a414b4dfc349bb8bb8f8eea5 100644 --- a/src/node/ext/call.cc +++ b/src/node/ext/call.cc @@ -168,8 +168,9 @@ Local<Value> ParseMetadata(const grpc_metadata_array *metadata_array) { } if (EndsWith(elem->key, "-bin")) { Nan::Set(array, index_map[elem->key], - Nan::CopyBuffer(elem->value, - elem->value_length).ToLocalChecked()); + MakeFastBuffer( + Nan::CopyBuffer(elem->value, + elem->value_length).ToLocalChecked())); } else { Nan::Set(array, index_map[elem->key], Nan::New(elem->value).ToLocalChecked()); diff --git a/src/node/src/metadata.js b/src/node/src/metadata.js index c1da70b1974f61aaef7e529a9f31de78ce46751e..5c24e46c9b2c8dc70003d442116725aaded38a70 100644 --- a/src/node/src/metadata.js +++ b/src/node/src/metadata.js @@ -59,6 +59,7 @@ function normalizeKey(key) { function validate(key, value) { if (_.endsWith(key, '-bin')) { if (!(value instanceof Buffer)) { + console.log(value.constructor.toString()); throw new Error('keys that end with \'-bin\' must have Buffer values'); } } else { @@ -173,7 +174,9 @@ Metadata.prototype._getCoreRepresentation = function() { Metadata._fromCoreRepresentation = function(metadata) { var newMetadata = new Metadata(); if (metadata) { - newMetadata._internal_repr = _.cloneDeep(metadata); + _.forOwn(metadata, function(value, key) { + newMetadata._internal_repr[key] = _.clone(value); + }); } return newMetadata; };