-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grpc-lwt: fetch status code from response header #58
Grpc-lwt: fetch status code from response header #58
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good find. This is definitely a bug and it looks like it was a regression introduced during a refactor in #22.
Just one suggestion, see below.
lib/grpc-lwt/client.ml
Outdated
@@ -44,7 +44,7 @@ let call ~service ~rpc ?(scheme = "https") ~handler ~(do_request : do_request) | |||
match response.status with | |||
| `OK -> | |||
let+ status = | |||
match H2.Headers.get headers "grpc-status" with | |||
match H2.Headers.get response.headers "grpc-status" with | |||
| Some _ -> Lwt.return (Grpc.Status.extract_status headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Some _ -> Lwt.return (Grpc.Status.extract_status headers) | |
| Some _ -> Lwt.return (Grpc.Status.extract_status response.headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also extract the status from the response headers, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I completely overlooked that second instance of headers
. I have made the change in the latest version of the PR.
cb28ccf
to
1e5b0c9
Compare
1e5b0c9
to
695d451
Compare
@tmcgilchrist please merge at your own discretion - I am not familiar with the lwt version myself. |
In `Grpc_lwt.Client.call, after receiving the response, the function checks for the response status code from the headers of the request. When this is not found, the function waits to receive the trailers from the remote to infer the response status code. If the response does not include any trailer received, the function will hang.
If needed, I can provide a working example where an ocaml grpc client hangs after calling a server implemented in rust/tonic, where the handler of the service returns status code
12: Unimplemented
.The client should look for the response status code from the headers of the response (not the request). The change is done in this PR.