Skip to content

Commit ac12ab0

Browse files
authored
chore: handle panics when joining on cancellations in ingress_watcher event loop (dfinity#3618)
This PR propagates panics from cancellations tasks.
1 parent e2a1f9c commit ac12ab0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

rs/http_endpoints/public/src/call/ingress_watcher.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,17 @@ impl IngressWatcher {
239239
self.handle_certification(*certified_height.borrow_and_update());
240240
}
241241
// Cancel the tracking of an ingress message.
242-
// TODO: Handle Some(Err(_)) case?
243-
Some(Ok((_, message_id))) = self.cancellations.join_next() => {
244-
self.metrics.ingress_watcher_cancelled_subscriptions_total.inc();
245-
self.handle_cancellation(&message_id);
242+
Some(cancellation_handle) = self.cancellations.join_next() => {
243+
match cancellation_handle {
244+
Ok((_, message_id)) => {
245+
self.metrics.ingress_watcher_cancelled_subscriptions_total.inc();
246+
self.handle_cancellation(&message_id);
247+
}
248+
// If the task panics we propagate the panic.
249+
Err(join_error) => if join_error.is_panic() {
250+
std::panic::resume_unwind(join_error.into_panic());
251+
}
252+
}
246253
}
247254

248255
_ = self.cancellation_token.cancelled() => {
@@ -478,7 +485,6 @@ mod tests {
478485
assert_eq!(ingress_watcher.completed_execution_heights.len(), 0);
479486
}
480487

481-
/// TODO: Can be removed. We have integration test covering the sames scenario.
482488
#[rstest]
483489
fn test_handling_of_duplicate_requests(mut ingress_watcher: IngressWatcher) {
484490
let message = MessageId::from([0; EXPECTED_MESSAGE_ID_LENGTH]);

0 commit comments

Comments
 (0)