Skip to content

Commit 4b9229a

Browse files
committed
f Bump shutdown timeout to 100s, fix superfluous panic
1 parent 9790e86 commit 4b9229a

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

src/lib.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -800,29 +800,37 @@ impl Node {
800800
let event_handling_stopped_logger = Arc::clone(&self.logger);
801801
let mut event_handling_stopped_receiver = self.event_handling_stopped_sender.subscribe();
802802

803-
let _ = runtime
804-
.block_on(async {
805-
tokio::time::timeout(
806-
Duration::from_secs(10),
807-
event_handling_stopped_receiver.changed(),
808-
)
809-
.await
810-
})
811-
.map_err(|e| {
803+
// FIXME: For now, we wait up to 100 secs (BDK_WALLET_SYNC_TIMEOUT_SECS + 10) to allow
804+
// event handling to exit gracefully even if it was blocked on the BDK wallet syncing. We
805+
// should drop this considerably post upgrading to BDK 1.0.
806+
let timeout_res = runtime.block_on(async {
807+
tokio::time::timeout(
808+
Duration::from_secs(100),
809+
event_handling_stopped_receiver.changed(),
810+
)
811+
.await
812+
});
813+
814+
match timeout_res {
815+
Ok(stop_res) => match stop_res {
816+
Ok(()) => {},
817+
Err(e) => {
818+
log_error!(
819+
event_handling_stopped_logger,
820+
"Stopping event handling failed. This should never happen: {}",
821+
e
822+
);
823+
panic!("Stopping event handling failed. This should never happen.");
824+
},
825+
},
826+
Err(e) => {
812827
log_error!(
813828
event_handling_stopped_logger,
814-
"Stopping event handling timed out. This should never happen: {}",
829+
"Stopping event handling timed out: {}",
815830
e
816831
);
817-
debug_assert!(false);
818-
})
819-
.unwrap_or_else(|_| {
820-
log_error!(
821-
event_handling_stopped_logger,
822-
"Stopping event handling failed. This should never happen.",
823-
);
824-
panic!("Stopping event handling failed. This should never happen.");
825-
});
832+
},
833+
}
826834

827835
#[cfg(tokio_unstable)]
828836
{

0 commit comments

Comments
 (0)