fix(ping): remove debug_assert on protocol negotiation timeout

The negotiation of the ping protocol can timeout, thus a debug_assert is not correct. Return an `std::io::Error` instead.

Pull-Request: #3995.
This commit is contained in:
Max Inden 2023-05-30 05:21:52 +02:00 committed by GitHub
parent a8a00e7ad7
commit efb117e236
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -196,10 +196,12 @@ impl Handler {
return;
}
// Note: This timeout only covers protocol negotiation.
StreamUpgradeError::Timeout => {
debug_assert!(false, "ReadyUpgrade cannot time out");
return;
}
StreamUpgradeError::Timeout => Failure::Other {
error: Box::new(std::io::Error::new(
std::io::ErrorKind::TimedOut,
"ping protocol negotiation timed out",
)),
},
StreamUpgradeError::Apply(e) => void::unreachable(e),
StreamUpgradeError::Io(e) => Failure::Other { error: Box::new(e) },
};