From 4ead1e47f4325a803205c0d0cf630ba7a900d758 Mon Sep 17 00:00:00 2001 From: Ruediger Klaehn Date: Wed, 21 Dec 2022 09:37:09 +0200 Subject: [PATCH] fix: ignore empty frames fixes false errors being logged --- src/transport/http2.rs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/transport/http2.rs b/src/transport/http2.rs index e16c1d4..632e5e0 100644 --- a/src/transport/http2.rs +++ b/src/transport/http2.rs @@ -273,22 +273,28 @@ impl ServerChannel { // This assumes each chunk received corresponds to a single HTTP2 frame. while let Some(chunk) = stream.next().await { match chunk { - Ok(chunk) => match bincode::deserialize::(chunk.as_ref()) { - Ok(msg) => { - event!(Level::TRACE, "Server got msg: {} bytes", chunk.len()); - match req_tx.send_async(msg).await { - Ok(()) => {} - Err(cause) => { - error!("Flume request channel closed: {}", cause); - break; + Ok(chunk) if !chunk.is_empty() => { + match bincode::deserialize::(chunk.as_ref()) { + Ok(msg) => { + event!(Level::TRACE, "Server got msg: {} bytes", chunk.len()); + match req_tx.send_async(msg).await { + Ok(()) => {} + Err(cause) => { + error!("Flume request channel closed: {}", cause); + break; + } } } + Err(cause) => { + error!("Failed to deserialise request as bincode: {}", cause); + break; + } } - Err(cause) => { - error!("Failed to deserialise request as bincode: {}", cause); - break; - } - }, + } + Ok(_) => { + // does an empty chunk always signal end of stream? + continue; + } Err(cause) => { error!("Failed to read request from networks: {}", cause); break;