From efb117e236e129bccc9ef4ddce3f87f1f2aeb7d0 Mon Sep 17 00:00:00 2001 From: Max Inden Date: Tue, 30 May 2023 05:21:52 +0200 Subject: [PATCH] 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. --- protocols/ping/src/handler.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/protocols/ping/src/handler.rs b/protocols/ping/src/handler.rs index 8ea0e327..0cf5c6e5 100644 --- a/protocols/ping/src/handler.rs +++ b/protocols/ping/src/handler.rs @@ -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) }, };