mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
fix websocket hangup error (#1981)
This commit is contained in:
@@ -86,9 +86,10 @@ async fn ws_handler<
|
|||||||
.with_kind(ErrorKind::Network)?;
|
.with_kind(ErrorKind::Network)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut ws_closed = false;
|
||||||
while let Some(entry) = tokio::select! {
|
while let Some(entry) = tokio::select! {
|
||||||
a = logs.try_next() => Some(a?),
|
a = logs.try_next() => Some(a?),
|
||||||
a = stream.try_next() => { a.with_kind(crate::ErrorKind::Network)?; None }
|
a = stream.try_next() => { a.with_kind(crate::ErrorKind::Network)?; ws_closed = true; None }
|
||||||
} {
|
} {
|
||||||
if let Some(entry) = entry {
|
if let Some(entry) = entry {
|
||||||
let (_, log_entry) = entry.log_entry()?;
|
let (_, log_entry) = entry.log_entry()?;
|
||||||
@@ -101,13 +102,15 @@ async fn ws_handler<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stream
|
if !ws_closed {
|
||||||
.close(Some(CloseFrame {
|
stream
|
||||||
code: CloseCode::Normal,
|
.close(Some(CloseFrame {
|
||||||
reason: "Log Stream Finished".into(),
|
code: CloseCode::Normal,
|
||||||
}))
|
reason: "Log Stream Finished".into(),
|
||||||
.await
|
}))
|
||||||
.with_kind(ErrorKind::Network)?;
|
.await
|
||||||
|
.with_kind(ErrorKind::Network)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user