Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a message for EOF-related broken pipe errors #615

Merged
merged 1 commit into from Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/proto/streams/state.rs
Expand Up @@ -303,7 +303,13 @@ impl State {
Closed(..) => {}
ref state => {
tracing::trace!("recv_eof; state={:?}", state);
self.inner = Closed(Cause::Error(io::ErrorKind::BrokenPipe.into()));
self.inner = Closed(Cause::Error(
io::Error::new(
io::ErrorKind::BrokenPipe,
"stream closed because of a broken pipe",
)
.into(),
));
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/proto/streams/streams.rs
Expand Up @@ -806,7 +806,13 @@ impl Inner {
let send_buffer = &mut *send_buffer;

if actions.conn_error.is_none() {
actions.conn_error = Some(io::Error::from(io::ErrorKind::BrokenPipe).into());
actions.conn_error = Some(
io::Error::new(
io::ErrorKind::BrokenPipe,
"connection closed because of a broken pipe",
)
.into(),
);
}

tracing::trace!("Streams::recv_eof");
Expand Down
9 changes: 6 additions & 3 deletions tests/h2-tests/tests/client_request.rs
Expand Up @@ -574,7 +574,7 @@ async fn connection_close_notifies_response_future() {
.0
.await;
let err = res.expect_err("response");
assert_eq!(err.to_string(), "broken pipe");
assert_eq!(err.to_string(), "stream closed because of a broken pipe");
};
join(async move { conn.await.expect("conn") }, req).await;
};
Expand Down Expand Up @@ -613,15 +613,18 @@ async fn connection_close_notifies_client_poll_ready() {
.0
.await;
let err = res.expect_err("response");
assert_eq!(err.to_string(), "broken pipe");
assert_eq!(err.to_string(), "stream closed because of a broken pipe");
};

conn.drive(req).await;

let err = poll_fn(move |cx| client.poll_ready(cx))
.await
.expect_err("poll_ready");
assert_eq!(err.to_string(), "broken pipe");
assert_eq!(
err.to_string(),
"connection closed because of a broken pipe"
);
};

join(srv, client).await;
Expand Down