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

improper error handling with from h2 reason::cancel -> tonic::code::unkown #848

Closed
lyang24 opened this issue Nov 26, 2021 · 11 comments · Fixed by #1315, #1337 or cloudwego/volo#198
Closed

Comments

@lyang24
Copy link

lyang24 commented Nov 26, 2021

Bug Report

Version: latest

Platform: all (linux)

Crates

http_body, hyper, h2

Description

maybe Streaming::message need to handle h2 error?

pub async fn message(&mut self) -> Result<Option<T>, Status> {

called from here
if let Some(trailers) = body.trailers().await? {

I expected to see this happen: Code::Cancelled, message: stream no longer needed

Instead, this happened: code: Unknown, message: "error reading a body from connection: stream error received: stream no longer needed

Todo add minimal reproduce example

@davidpdrsn
Copy link
Member

Are you able to share a minimal reproducible example?

@lyang24
Copy link
Author

lyang24 commented Nov 26, 2021

Are you able to share a minimal reproducible example?

not yet sorry i am not that skilled in rust. but if h2 will throws an error with reason::cancel and that is propagated by hyper's poll_inner fn at hyper/src/body/body.rs the downcast here will not catch it right? then it will be code::unknown mixed with hyper's message instead of code::cancelled which is confusing

@davidpdrsn
Copy link
Member

Hyper errors have h2 errors as the "source" which should get picked up by tonic. At least I remember doing a bunch of testing around that last time we worked on it.

@lyang24
Copy link
Author

lyang24 commented Nov 26, 2021

Hyper errors have h2 errors as the "source" which should get picked up by tonic. At least I remember doing a bunch of testing around that last time we worked on it.

maybe its a version issue let me double check, close the report for now

@lyang24 lyang24 closed this as completed Nov 26, 2021
@lyang24
Copy link
Author

lyang24 commented Nov 26, 2021

@davidpdrsn yep you are right hyper have h2 error as source. i have a quick question should we handle h2 error here since we are polling from the stream? i guess this is where the code known come from? will google how to repo bug with custom dependencies tmr. its way to late today.

pub async fn message(&mut self) -> Result<Option<T>, Status> {

@lyang24 lyang24 changed the title improper error handling with struct Status try_from error improper error handling with from h2 reason::cancel -> tonic::code::unkown Nov 26, 2021
@lyang24
Copy link
Author

lyang24 commented Nov 26, 2021

updated desc reopen and will work towards an example tmr

@lyang24 lyang24 reopened this Nov 26, 2021
@LucioFranco LucioFranco added this to the 0.7 milestone Dec 7, 2021
@inevity
Copy link

inevity commented Jan 13, 2022

Though we have get fn from_h2_error(err: &h2::Error), but this is not exhaust.
When set timeout 1us by tower service-builder.new().settimeout() layer then server build the tonic. The grpc server will timeout some req.
h2 log this:
http2 service errored: error from user's Service: request timed out,
and tonic rpc will get response : code: Unknow, message: transport error.

@LucioFranco
Copy link
Member

In this case you will need to downcast to the timeout error since you added that layer it looks like and tonic doesn't directly map those timeout errors on the server side iirc

@LucioFranco
Copy link
Member

@lyang24 did you ever get a chance to get a repro?

@LucioFranco LucioFranco removed this from the 0.7 milestone Mar 22, 2022
@behos
Copy link

behos commented Mar 7, 2023

Hi @LucioFranco , here's a rough implementation reproducing the error handling

https://github.com/behos/tonic-bidi-error

LucioFranco added a commit that referenced this issue Mar 13, 2023
This PR fixes how client side streaming is handled on the server side
and improves overall source error matching.

Fixes:

- Correctly, detect h2 codes when its wrapped in a hyper error.
- Cancelled requests from the client side during client streaming
  requests correctly return EOF (`None` from `Streaming::message()`)

Closes #848
LucioFranco added a commit that referenced this issue Mar 13, 2023
This PR fixes how client side streaming is handled on the server side
and improves overall source error matching.

Fixes:

- Correctly, detect h2 codes when its wrapped in a hyper error.
- Cancelled requests from the client side during client streaming
  requests correctly return EOF (`None` from `Streaming::message()`)

Closes #848
@LucioFranco
Copy link
Member

Ok I have a fix here for it #1315 feel free to review it.

LucioFranco added a commit that referenced this issue Mar 14, 2023
This PR fixes how client side streaming is handled on the server side
and improves overall source error matching.

Fixes:

- Correctly, detect h2 codes when its wrapped in a hyper error.
- Cancelled requests from the client side during client streaming
  requests correctly return EOF (`None` from `Streaming::message()`)

Closes #848
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants