hyperium / tonic

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

Bug: user-defined `max_decoding_message_size` is not used in some cases (client streaming response decoding) #1353

Closed checkline1052 closed 1 year ago

checkline1052 commented 1 year ago

Bug Report

Version

tonic 0.9.1 tonic-build 0.9.1

Platform

Fedora 37 x86_64

Crates

tonic

Description

I recently updated tonic to v0.9.1, and I experienced breaking changes due to DEFAULT_MAX_RECV_MESSAGE_SIZE. It's ok, we can increase this limit with max_decoding_message_size() and max_encoding_message_size() (in both server and client !), and it did fix "message lenth too large" errors for normal requests/responses (I increased it to 60MB).

However, I still have these errors in stream responses decoding, when calling if let Some(stream_response) = request.message().await.unwrap() :

TonicStatus status: OutOfRange, message "Error, message length too large: found 6877902 bytes, the limit is: 4194304 bytes", details: [], metadata: MetadataMap { headers: {} }

In Grpc::create_response() if found that in a some cases, the codec::decode::Streaming is created without the user-defined max_decoding_message_size, when calling Streaming::new_empty(...) here : https://github.com/hyperium/tonic/blob/9990e6ef9d00394b5662719662062cc85e6e4700/tonic/src/client/grpc.rs#L352-L364

But I do no have a complete understanding of the tonic crate, so I did not open a pull-request for this issue yet

Thank you !

LucioFranco commented 1 year ago

Hi @checkline1052, I wrote a test to try and reproduce what you were stating above but from what I can tell everything works as intended. Please take a look at https://github.com/hyperium/tonic/pull/1363 and see if this differs from your code.

checkline1052 commented 1 year ago

Thanks you for the integration test, I was doing something wrong !