Skip to content
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

Conversation

acerone85
Copy link
Contributor

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.

Copy link
Collaborator

@quernd quernd left a 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.

@@ -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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| Some _ -> Lwt.return (Grpc.Status.extract_status headers)
| Some _ -> Lwt.return (Grpc.Status.extract_status response.headers)

Copy link
Collaborator

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?

Copy link
Contributor Author

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.

@acerone85 acerone85 force-pushed the acerone85@grpc-lwt-fix-status-response-header branch from cb28ccf to 1e5b0c9 Compare May 4, 2024 22:02
@acerone85 acerone85 force-pushed the acerone85@grpc-lwt-fix-status-response-header branch from 1e5b0c9 to 695d451 Compare May 4, 2024 22:08
@wokalski
Copy link
Contributor

@tmcgilchrist please merge at your own discretion - I am not familiar with the lwt version myself.

@tmcgilchrist tmcgilchrist merged commit 6fe6cfe into dialohq:main May 17, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants