Skip to content

Commit

Permalink
fix(terminal): add more error handling
Browse files Browse the repository at this point in the history
Also stop polling main websocket on terminal page
  • Loading branch information
ravenclaw900 committed Feb 6, 2022
1 parent c5ebc71 commit 7b1c051
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
13 changes: 8 additions & 5 deletions src/backend/src/socket_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ pub async fn socket_handler(socket: warp::ws::WebSocket) {
)))
.await;
}
_ => {}
_ => {
log::debug!("Got page {}, not handling", message.page);
}
}
}
}
Expand Down Expand Up @@ -174,7 +176,9 @@ pub async fn term_handler(socket: warp::ws::WebSocket) {
.await
.unwrap();
if result.0.is_ok() {
send.send(result.1).await.unwrap();
if send.send(result.1).await.is_err() {
break;
}
} else {
quit_send.notify_one();
break;
Expand All @@ -198,10 +202,9 @@ pub async fn term_handler(socket: warp::ws::WebSocket) {
if let Some(Ok(data_unwrapped)) = data_msg {
data = data_unwrapped;
} else {
(*cmd_write.read().await)
let _write = (*cmd_write.read().await)
.pty()
.write_all("exit\n".as_bytes())
.unwrap();
.write_all("exit\n".as_bytes());
continue;
}
if data.is_text() && data.to_str().unwrap().get(..4) == Some("size") {
Expand Down
Binary file modified src/frontend/.yarn/install-state.gz
Binary file not shown.
25 changes: 14 additions & 11 deletions src/frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,21 @@
};
function pollServer(page: string) {
let json: string;
if (login) {
json = JSON.stringify({
page,
token,
});
} else {
json = JSON.stringify({
page,
});
if (page != "/terminal") {
// Terminal doesn't work if sent
let json: string;
if (login) {
json = JSON.stringify({
page,
token,
});
} else {
json = JSON.stringify({
page,
});
}
socket.send(json);
}
socket.send(json);
}
function changePage(page: string) {
Expand Down

0 comments on commit 7b1c051

Please sign in to comment.