Avoid a rare panic when a connection is dropped (#6566)

This commit is contained in:
teor 2023-04-26 12:47:35 +10:00 committed by GitHub
parent e831e1b0dd
commit a1b3246d0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -621,8 +621,13 @@ impl Service<Request> for Client {
Ok(()) => {
// The receiver end of the oneshot is itself a future.
rx.map(|oneshot_recv_result| {
oneshot_recv_result
.expect("ClientRequest oneshot sender must not be dropped before send")
// The ClientRequest oneshot sender should not be dropped before sending a
// response. But sometimes that happens during process or connection shutdown.
// So we just return a generic error here.
match oneshot_recv_result {
Ok(result) => result,
Err(oneshot::Canceled) => Err(PeerError::ConnectionDropped.into()),
}
})
.boxed()
}