Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions crates/watcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ where
time_interval.tick().await;
let result = function().await;
match result {
Ok(value) => tx.send(value).expect("Failed to update channel"),
Ok(value) => {
if tx.send(value).is_err() {
tracing::debug!("Watcher channel closed, stopping watcher task");
break;
}
}
Err(err) => {
// TODO mark it as delayed
tracing::warn!(error = %err, "There was an error while updating watcher");
Expand Down Expand Up @@ -79,7 +84,10 @@ where
let current_val_1 = receiver_1.borrow().clone();
let current_val_2 = receiver_2.borrow().clone();
let mapped_value = map_function((current_val_1, current_val_2));
tx.send(mapped_value).expect("Failed to update channel");
if tx.send(mapped_value).is_err() {
tracing::debug!("Watcher channel closed, stopping combined watcher task");
break;
}
}
});
rx
Expand Down Expand Up @@ -138,7 +146,10 @@ where

let current_val = receiver.borrow().clone();
let mapped_value = map_function(current_val);
tx.send(mapped_value).expect("Failed to update channel");
if tx.send(mapped_value).is_err() {
tracing::debug!("Watcher channel closed, stopping mapped watcher task");
break;
}
}
});
rx
Expand Down
Loading