d4b149046f
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. |
||
---|---|---|
.. | ||
debug | ||
mock | ||
rpc | ||
buffer.go | ||
context.go | ||
debug.go | ||
extractor_test.go | ||
extractor.go | ||
handler.go | ||
options.go | ||
rpc_codec_test.go | ||
rpc_codec.go | ||
rpc_handler.go | ||
rpc_request.go | ||
rpc_server.go | ||
rpc_service.go | ||
rpc_stream.go | ||
server_wrapper.go | ||
server.go | ||
subscriber.go |