Hao Lian d4b149046f server/rpc_codec: if c.codec.Write fails, reset write buffer and encode an error message about the encoding failure
When developing go-micro services, it is frequently possible to set invalid results in the response pointer. When this happens (as I and @trushton personally experienced), `sendResponse()` returns an error correctly explaining what happened (e.g. protobuf refused to encode a bad struct) but the `call()` function one above it in the stack ignores the returned error object.

Thus, invalid structs go un-encoded and the _client side times out_. @trushton and I first caught this in our CI builds when we left a protobuf.Empty field uninitialized (nil) instead of setting it to `&ptypes.Empty{}`. This resulted in an `proto: oneof field has nil value` error, but it was dropped and became a terribly confusing client timeout instead.

This patch is two independent changes:

* In rpc_codec, when a serialization failure occurs serialize an error message, which will correctly become a 500 for HTTP services, about the encoding failure. This means rpc_codec only returns an `error` when a socket failure occurs, which I believe is the behavior that rpc_service is expecting anyway.

* In rpc_service, log any errors returned by sendResponse instead of dropping the error object. This will make debugging client timeouts less of a hassle.
2017-07-17 14:21:43 -04:00
..
2016-05-28 22:30:47 +01:00
2016-04-16 00:02:55 +01:00
2016-03-14 10:45:38 +00:00
2017-05-31 19:33:11 +01:00
2016-05-28 22:30:47 +01:00
2017-01-12 13:20:34 +00:00
2017-01-12 13:20:34 +00:00
2016-05-26 20:43:05 +01:00
2017-05-31 19:47:50 +01:00
2016-05-26 18:01:02 +01:00
2016-12-15 20:45:27 +00:00
2015-12-18 01:01:59 +00:00
2017-05-11 20:43:42 +01:00