Skip to content

Commit

Permalink
fix: try to print error message when reading lines
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Jun 22, 2024
1 parent 7edeaff commit ca48fe3
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions worker/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,23 @@ async fn get_output_logged(
let mut res = String::new();
if let Some(io) = io.as_mut() {
let mut reader = BufReader::new(io).lines();
while let Ok(Some(v)) = reader.next_line().await {
for line in v.split("\r") {
tx.send_async(Message::Text(line.to_string())).await.ok();
res += &line;
res += "\n";
loop {
match reader.next_line().await {
Ok(Some(v)) => {
for line in v.split("\r") {
tx.send_async(Message::Text(line.to_string())).await.ok();
res += &line;
res += "\n";
}
}
Ok(None) => {
info!("No more lines to read");
break;
}
Err(err) => {
warn!("Failed to read next line: {err}");
break;
}
}
}
}
Expand Down

0 comments on commit ca48fe3

Please sign in to comment.