Skip to content

Commit

Permalink
fix: do not panic on full channels
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeStanger committed Jan 29, 2024
1 parent cc39896 commit 0616633
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ macro_rules! glib_recv {
glib::spawn_future_local(async move {
// re-delcare in case ie `context.subscribe()` is passed directly
let mut rx = $rx;
while let Ok($val) = rx.recv().await {
$expr
loop {
match rx.recv().await {
Ok($val) => $expr,
Err(tokio::sync::broadcast::error::RecvError::Lagged(count)) => {
tracing::warn!("Channel lagged behind by {count}, this may result in unexpected or broken behaviour");
}
Err(err) => {
tracing::error!("{err:?}");
break;
}
}
}
});
}};
Expand Down

0 comments on commit 0616633

Please sign in to comment.