Skip to content
Snippets Groups Projects
Commit dbda9206 authored by murgatroid99's avatar murgatroid99
Browse files

Also propagate serialization errors in unary server responses

parent c13e2f5b
No related branches found
No related tags found
No related merge requests found
...@@ -127,7 +127,13 @@ function sendUnaryResponse(call, value, serialize, metadata, flags) { ...@@ -127,7 +127,13 @@ function sendUnaryResponse(call, value, serialize, metadata, flags) {
(new Metadata())._getCoreRepresentation(); (new Metadata())._getCoreRepresentation();
call.metadataSent = true; call.metadataSent = true;
} }
var message = serialize(value); var message;
try {
message = serialize(value);
} catch (e) {
e.code = grpc.status.INTERNAL;
handleError(e);
}
message.grpcWriteFlags = flags; message.grpcWriteFlags = flags;
end_batch[grpc.opType.SEND_MESSAGE] = message; end_batch[grpc.opType.SEND_MESSAGE] = message;
end_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status; end_batch[grpc.opType.SEND_STATUS_FROM_SERVER] = status;
...@@ -282,7 +288,9 @@ function _write(chunk, encoding, callback) { ...@@ -282,7 +288,9 @@ function _write(chunk, encoding, callback) {
try { try {
message = this.serialize(chunk); message = this.serialize(chunk);
} catch (e) { } catch (e) {
e.code = grpc.status.INTERNAL;
callback(e); callback(e);
return;
} }
if (_.isFinite(encoding)) { if (_.isFinite(encoding)) {
/* Attach the encoding if it is a finite number. This is the closest we /* Attach the encoding if it is a finite number. This is the closest we
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment