From cf9a7a02efc9e8eeeead0dbabc3af8cd9da0ac3f Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sun, 27 Sep 2020 22:04:37 -0600 Subject: [PATCH] Don't panic if events are lagged --- src/update_listener.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/update_listener.rs b/src/update_listener.rs index baa88e9..91945f7 100644 --- a/src/update_listener.rs +++ b/src/update_listener.rs @@ -7,7 +7,7 @@ use tokio::{ sync::{broadcast, oneshot}, task::JoinHandle, }; -use tracing::{trace, trace_span}; +use tracing::{trace, trace_span, warn}; use tracing_futures::Instrument; struct UpdateListenerTask { @@ -21,13 +21,17 @@ impl UpdateListenerTask { event: Result, ) -> eyre::Result<()> { let event = match event { + Ok(ev) => ev, Err(broadcast::RecvError::Closed) => { trace!("section events channel closed"); self.running = false; return Ok(()); } - e => e, - }?; + Err(broadcast::RecvError::Lagged(n)) => { + warn!("section events lagged by {}", n); + return Ok(()); + } + }; if let Some((sec_id, state)) = match event { SectionEvent::RunStart(_, sec) | SectionEvent::RunUnpause(_, sec) => { Some((sec.id, true))