@@ -804,29 +804,37 @@ impl Node {
804804 let event_handling_stopped_logger = Arc :: clone ( & self . logger ) ;
805805 let mut event_handling_stopped_receiver = self . event_handling_stopped_sender . subscribe ( ) ;
806806
807- let _ = runtime
808- . block_on ( async {
809- tokio:: time:: timeout (
810- Duration :: from_secs ( 10 ) ,
811- event_handling_stopped_receiver. changed ( ) ,
812- )
813- . await
814- } )
815- . map_err ( |e| {
807+ // FIXME: For now, we wait up to 100 secs (BDK_WALLET_SYNC_TIMEOUT_SECS + 10) to allow
808+ // event handling to exit gracefully even if it was blocked on the BDK wallet syncing. We
809+ // should drop this considerably post upgrading to BDK 1.0.
810+ let timeout_res = runtime. block_on ( async {
811+ tokio:: time:: timeout (
812+ Duration :: from_secs ( 100 ) ,
813+ event_handling_stopped_receiver. changed ( ) ,
814+ )
815+ . await
816+ } ) ;
817+
818+ match timeout_res {
819+ Ok ( stop_res) => match stop_res {
820+ Ok ( ( ) ) => { } ,
821+ Err ( e) => {
822+ log_error ! (
823+ event_handling_stopped_logger,
824+ "Stopping event handling failed. This should never happen: {}" ,
825+ e
826+ ) ;
827+ panic ! ( "Stopping event handling failed. This should never happen." ) ;
828+ } ,
829+ } ,
830+ Err ( e) => {
816831 log_error ! (
817832 event_handling_stopped_logger,
818- "Stopping event handling timed out. This should never happen : {}" ,
833+ "Stopping event handling timed out: {}" ,
819834 e
820835 ) ;
821- debug_assert ! ( false ) ;
822- } )
823- . unwrap_or_else ( |_| {
824- log_error ! (
825- event_handling_stopped_logger,
826- "Stopping event handling failed. This should never happen." ,
827- ) ;
828- panic ! ( "Stopping event handling failed. This should never happen." ) ;
829- } ) ;
836+ } ,
837+ }
830838
831839 #[ cfg( tokio_unstable) ]
832840 {
0 commit comments