Skip to content

Commit

Permalink
Bandaid for intermittent hanging when hyper::body::to_bytes is called
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbeitz committed Dec 5, 2023
1 parent 35a31b2 commit b4ff631
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions core/common/src/grpc_interceptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,16 @@ where
if is_applicable && interceptor.must_handle_request() {
let (parts, body) = request.into_parts();

// Rust requires that we initilaize body_bytes_timeout_result.
// Note: We will never use the initilaized value, so using an Ok value is fine.
let mut body_bytes_timeout_result = Ok(Ok(Bytes::new()));

// There is a known issue where hyper::body::to_bytes sometimes hangs in the code below.
// We will use a timeout to break out when this happens. This fix is a bandaid. We will
// implement a better fix after we have upgraded to the latest major version of the hyper crate.
futures::executor::block_on(async {
body_bytes_timeout_result = async_std::future::timeout(
let mut body_bytes: Bytes = match futures::executor::block_on(async {
async_std::future::timeout(
core::time::Duration::from_secs(5),
hyper::body::to_bytes(body),
)
.await;
});

let mut body_bytes: Bytes = match body_bytes_timeout_result {
.await
}) {
Ok(Ok(bytes)) => bytes,
Ok(Err(err)) => {
return Box::pin(async move {
Expand Down

0 comments on commit b4ff631

Please sign in to comment.