Skip to content

Commit

Permalink
Add @mbacarella's check for complete absence of grpc-status
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor-pi committed Mar 27, 2022
1 parent a5fdc47 commit f790382
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/grpc-async/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ let call ~service ~rpc ?(scheme = "https") ~handler ~do_request
Ivar.fill handler_res_ivar handler_res;
return ());
let%bind out = Ivar.read out_ivar in
let%bind trailers_status = Ivar.read trailers_status_ivar in
let%bind trailers_status =
(* In case no grpc-status appears in headers or trailers. *)
if Ivar.is_full trailers_status_ivar then Ivar.read trailers_status_ivar
else return (Grpc.Status.v ~message:"Server did not return grpc-status" Grpc.Status.Unknown)
in
match out with
| Error _ as e -> return e
| Ok out -> return (Ok (out, trailers_status))
Expand Down
7 changes: 6 additions & 1 deletion lib/grpc-lwt/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ let call ~service ~rpc ?(scheme = "https") ~handler ~do_request
let+ handler_res = handler write_body read_body in
Lwt.wakeup_later handler_res_notify handler_res);
let* out in
let+ status in
let+ status =
match Lwt.state status with
(* In case no grpc-status appears in headers or trailers. *)
| Sleep -> let+ status in status
| _ -> Lwt.return @@ Grpc.Status.v ~message:"Server did not return grpc-status" Grpc.Status.Unknown
in
match out with Error _ as e -> e | Ok out -> Ok (out, status)

module Rpc = struct
Expand Down

0 comments on commit f790382

Please sign in to comment.