Skip to content

Commit

Permalink
Fix tokio runtime starvation+log spamming due to TCP broken pipe errors
Browse files Browse the repository at this point in the history
This relates to hyperium/tonic#222
  • Loading branch information
nmdanny committed Mar 8, 2021
1 parent d84460c commit ed42ca1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/grpc/pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,17 @@ pub fn tonic_stream_to_raft<EventType: Value>(tonic_result: Result<tonic::Respon
-> Result<EventStream<EventType>, RaftError> {
match tonic_result {
Ok(res) => {
Ok(Box::pin(res.into_inner().filter_map(|res| {
Ok(Box::pin(res.into_inner()
.take_while(|res| {
if let Err(err) = res {
if err.message().contains("broken pipe") {
error!("There was an error while receiving stream-element during tonic_stream_to_raft which requires terminating the stream: {:?}", err);
return false;
}
}
true
})
.filter_map(|res| {
match res {
Ok(generic_message) => {
let deser = serde_json::from_slice::<EventType>(&generic_message.buf);
Expand Down

0 comments on commit ed42ca1

Please sign in to comment.