Skip to content

Commit

Permalink
Merge pull request #2102 from murgatroid99/grpc-js_no_unary_response
Browse files Browse the repository at this point in the history
grpc-js: Report error when no message received for unary response
  • Loading branch information
murgatroid99 committed Apr 20, 2022
2 parents fa92727 + 5311c03 commit 028047f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/grpc-js/src/client.ts
Expand Up @@ -338,7 +338,15 @@ export class Client {
}
receivedStatus = true;
if (status.code === Status.OK) {
callProperties.callback!(null, responseMessage!);
if (responseMessage === null) {
callProperties.callback!(callErrorFromStatus({
code: Status.INTERNAL,
details: 'No message received',
metadata: status.metadata
}));
} else {
callProperties.callback!(null, responseMessage);
}
} else {
callProperties.callback!(callErrorFromStatus(status));
}
Expand Down Expand Up @@ -455,7 +463,15 @@ export class Client {
}
receivedStatus = true;
if (status.code === Status.OK) {
callProperties.callback!(null, responseMessage!);
if (responseMessage === null) {
callProperties.callback!(callErrorFromStatus({
code: Status.INTERNAL,
details: 'No message received',
metadata: status.metadata
}));
} else {
callProperties.callback!(null, responseMessage);
}
} else {
callProperties.callback!(callErrorFromStatus(status));
}
Expand Down

0 comments on commit 028047f

Please sign in to comment.