Skip to content

Commit

Permalink
Merge pull request #2346 from dusk-network/fix-ws-disconnect
Browse files Browse the repository at this point in the history
rusk: RUES - handle Connection reset without closing handshake
  • Loading branch information
herr-seppia authored Sep 11, 2024
2 parents 955d6b9 + 592585b commit c1473c2
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions rusk/src/lib/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) use event::{
};

use execution_core::Event;
use tracing::{info, warn};
use tracing::{debug, info, warn};

use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -484,9 +484,29 @@ async fn handle_stream_rues<H: HandleRequest>(
loop {
tokio::select! {
recv = stream.next() => {
if let Some(Ok(Message::Close(msg))) = recv {
let _ = stream.close(msg).await;
break;
match (recv) {
Some(Ok(Message::Close(msg))) => {
debug!("Closing stream for {sid} due to {msg:?}");
let _ = stream.close(msg).await;
break;
}
Some(Err(e)) => {
let _ = stream.close(Some(CloseFrame {
code: CloseCode::Error,
reason: Cow::from("Internal error"),
})).await;
warn!("Closing stream for {sid} due to {e}");
break;
}
None => {
let _ = stream.close(Some(CloseFrame {
code: CloseCode::Error,
reason: Cow::from("No more events"),
})).await;
warn!("Closing stream for {sid} due to no more events");
break;
}
_ => {}
}
}
_ = shutdown.recv() => {
Expand Down

0 comments on commit c1473c2

Please sign in to comment.