Merge remote-tracking branch 'upstream/v1.4.x' into master_1.4.1_upmerge

This commit is contained in:
murgatroid99 2017-07-06 10:15:11 -07:00
commit 128ed76cdd
4 changed files with 25 additions and 8 deletions

View File

@ -383,7 +383,10 @@ class ClientStatusOp : public Op {
public:
ClientStatusOp() { grpc_metadata_array_init(&metadata_array); }
~ClientStatusOp() { grpc_metadata_array_destroy(&metadata_array); }
~ClientStatusOp() {
grpc_metadata_array_destroy(&metadata_array);
grpc_slice_unref(status_details);
}
bool ParseOp(Local<Value> value, grpc_op *out) {
out->data.recv_status_on_client.trailing_metadata = &metadata_array;

View File

@ -137,6 +137,7 @@ function _write(chunk, encoding, callback) {
/* Once a write fails, just call the callback immediately to let the caller
flush any pending writes. */
setImmediate(callback);
return;
}
try {
message = this.serialize(chunk);
@ -149,6 +150,7 @@ function _write(chunk, encoding, callback) {
this.call.cancelWithStatus(constants.status.INTERNAL,
'Serialization failure');
callback(e);
return;
}
if (_.isFinite(encoding)) {
/* Attach the encoding if it is a finite number. This is the closest we

View File

@ -49,7 +49,7 @@ exports.deserializeCls = function deserializeCls(cls, options) {
* @return {cls} The resulting object
*/
return function deserialize(arg_buf) {
return cls.decode(arg_buf).toObject(conversion_options);
return cls.toObject(cls.decode(arg_buf), conversion_options);
};
};

View File

@ -1398,13 +1398,25 @@ describe('Client reconnect', function() {
});
server.bind('localhost:' + port, server_insecure_creds);
server.start();
client.echo(undefined, function(error, response) {
if (error) {
console.log(error);
}
/* We create a new client, that will not throw an error if the server
* is not immediately available. Instead, it will wait for the server
* to be available, then the call will complete. Once this happens, the
* original client should be able to make a new call and connect to the
* restarted server without having the call fail due to connection
* errors. */
var client2 = new Client('localhost:' + port,
grpc.credentials.createInsecure());
client2.echo({value: 'test', value2: 3}, function(error, response) {
assert.ifError(error);
assert.deepEqual(response, {value: '', value2: 0});
done();
client.echo(undefined, function(error, response) {
if (error) {
console.log(error);
}
assert.ifError(error);
assert.deepEqual(response, {value: '', value2: 0});
done();
});
});
});
});