File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,10 @@ class SentrySpan extends ISentrySpan {
7878    }
7979
8080    // Dispatch OnSpanFinish lifecycle event 
81-     await  _hub.options.lifecycleRegistry.dispatchCallback (OnSpanFinish (this ));
81+     final  callback =  _hub.options.lifecycleRegistry.dispatchCallback (OnSpanFinish (this ));
82+     if  (callback is  Future ) {
83+       await  callback;
84+     }
8285
8386    // The finished flag depends on the _endTimestamp 
8487    // If we set this earlier then finished is true and then we cannot use setData etc... 
Original file line number Diff line number Diff line change @@ -34,7 +34,17 @@ class SdkLifecycleRegistry {
3434    callbacks? .remove (callback);
3535  }
3636
37-   FutureOr <void > dispatchCallback <T  extends  SdkLifecycleEvent >(T  event) async  {
37+   FutureOr <void > dispatchCallback <T  extends  SdkLifecycleEvent >(T  event) {
38+     final  callbacks =  _lifecycleCallbacks[event.runtimeType];
39+     if  (callbacks ==  null  ||  callbacks.isEmpty) {
40+       // Return synchronously when there are no callbacks to avoid unnecessary async boundary 
41+       return  null ;
42+     }
43+     return  _dispatchCallbackAsync (event, callbacks);
44+   }
45+ 
46+   Future <void > _dispatchCallbackAsync <T  extends  SdkLifecycleEvent >(
47+       T  event, List <Function > callbacks) async  {
3848    final  callbacks =  _lifecycleCallbacks[event.runtimeType] ??  [];
3949    for  (final  cb in  callbacks) {
4050      try  {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments