Skip to content

Commit

Permalink
Return an error instead of panicking on shutdown (#5530)
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 authored Nov 2, 2022
1 parent e380676 commit c5e6adc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tower-batch/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,16 @@ where
{
match Pin::new(worker_handle).poll(cx) {
Poll::Ready(Ok(())) => return Poll::Ready(Err(self.get_worker_error())),
Poll::Ready(task_panic) => {
task_panic.expect("unexpected panic in batch worker task")
Poll::Ready(Err(task_cancelled)) if task_cancelled.is_cancelled() => {
tracing::warn!(
"batch task cancelled: {task_cancelled}\n\
Is Zebra shutting down?"
);

return Poll::Ready(Err(task_cancelled.into()));
}
Poll::Ready(Err(task_panic)) => {
std::panic::resume_unwind(task_panic.into_panic());
}
Poll::Pending => {}
}
Expand Down

0 comments on commit c5e6adc

Please sign in to comment.