Skip to content

Commit 96caf4f

Browse files
authored
Add a message for EOF-related broken pipe errors (#615)
It's quite confusing from production logs when all I get is "broken pipe" and I don't know which path was taken for that error to be logged.
1 parent 7323190 commit 96caf4f

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/proto/streams/state.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,13 @@ impl State {
303303
Closed(..) => {}
304304
ref state => {
305305
tracing::trace!("recv_eof; state={:?}", state);
306-
self.inner = Closed(Cause::Error(io::ErrorKind::BrokenPipe.into()));
306+
self.inner = Closed(Cause::Error(
307+
io::Error::new(
308+
io::ErrorKind::BrokenPipe,
309+
"stream closed because of a broken pipe",
310+
)
311+
.into(),
312+
));
307313
}
308314
}
309315
}

src/proto/streams/streams.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,13 @@ impl Inner {
806806
let send_buffer = &mut *send_buffer;
807807

808808
if actions.conn_error.is_none() {
809-
actions.conn_error = Some(io::Error::from(io::ErrorKind::BrokenPipe).into());
809+
actions.conn_error = Some(
810+
io::Error::new(
811+
io::ErrorKind::BrokenPipe,
812+
"connection closed because of a broken pipe",
813+
)
814+
.into(),
815+
);
810816
}
811817

812818
tracing::trace!("Streams::recv_eof");

tests/h2-tests/tests/client_request.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ async fn connection_close_notifies_response_future() {
574574
.0
575575
.await;
576576
let err = res.expect_err("response");
577-
assert_eq!(err.to_string(), "broken pipe");
577+
assert_eq!(err.to_string(), "stream closed because of a broken pipe");
578578
};
579579
join(async move { conn.await.expect("conn") }, req).await;
580580
};
@@ -613,15 +613,18 @@ async fn connection_close_notifies_client_poll_ready() {
613613
.0
614614
.await;
615615
let err = res.expect_err("response");
616-
assert_eq!(err.to_string(), "broken pipe");
616+
assert_eq!(err.to_string(), "stream closed because of a broken pipe");
617617
};
618618

619619
conn.drive(req).await;
620620

621621
let err = poll_fn(move |cx| client.poll_ready(cx))
622622
.await
623623
.expect_err("poll_ready");
624-
assert_eq!(err.to_string(), "broken pipe");
624+
assert_eq!(
625+
err.to_string(),
626+
"connection closed because of a broken pipe"
627+
);
625628
};
626629

627630
join(srv, client).await;

0 commit comments

Comments
 (0)