From 2a63b1a41f5c3d7490829a481474ebd7a9e4812a Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Thu, 30 Mar 2023 12:46:34 -0700 Subject: [PATCH] Downgrade I/O stream closing to warning. Since active I/O streams will be closed by graceful shutdown, an error, as was previously emitted, was necessarily alarmist. This reduces the severity of the log message to a warning. --- core/lib/src/server.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/lib/src/server.rs b/core/lib/src/server.rs index 9a473a2c..213a3214 100644 --- a/core/lib/src/server.rs +++ b/core/lib/src/server.rs @@ -173,22 +173,26 @@ impl Rocket { async fn handle_upgrade<'r>( &self, mut response: Response<'r>, - protocol: uncased::Uncased<'r>, + proto: uncased::Uncased<'r>, mut io_handler: Box, pending_upgrade: hyper::upgrade::OnUpgrade, tx: oneshot::Sender>, ) { - info_!("Upgrading connection to {}.", Paint::white(&protocol)); + info_!("Upgrading connection to {}.", Paint::white(&proto).bold()); response.set_status(Status::SwitchingProtocols); response.set_raw_header("Connection", "Upgrade"); - response.set_raw_header("Upgrade", protocol.into_cow()); + response.set_raw_header("Upgrade", proto.clone().into_cow()); self.send_response(response, tx).await; match pending_upgrade.await { Ok(io_stream) => { info_!("Upgrade successful."); if let Err(e) = io_handler.io(io_stream.into()).await { - error!("Upgraded I/O handler failed: {}", e); + if e.kind() == io::ErrorKind::BrokenPipe { + warn!("Upgraded {} I/O handler was closed.", proto); + } else { + error!("Upgraded {} I/O handler failed: {}", proto, e); + } } }, Err(e) => {