hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
9.35k stars 957 forks source link

Response::new does not send grpc-status code correctly #1716

Open heartforit opened 1 month ago

heartforit commented 1 month ago

Bug Report

Grpc-web won't work with tonic. It does not send the grpc-status header correctly when only using Response::new which leads on the js client side to the error "Error: Response closed without grpc-status (Headers only)"

Version

Platform

Windows 11 64bit

Description

I tried to run Response::new(someType) it returns the data correctly but won't set the header. However if I send Status::invalid_argument("Name cannot be empty") Things work out just as intended.

My question is: Is this defined behavior? Because the client expects a status code. If this is not needed the client library should ignore this case then.

Here is a screenshot from the problem: Screenshot_github

heartforit commented 1 month ago

It seems like "Response::new" sets the status code 2 => which means unknown. Client libraries expect 0 => 0K which does colide here. Is it possible to set the code manually within the response?