File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,10 @@ public class Server<
101101        } 
102102    } 
103103
104+     deinit  { 
105+         subscriptionTasks. values. forEach  {  $0. cancel ( )  } 
106+     } 
107+ 
104108    /// Define a custom callback run during `connection_init` resolution that allows authorization using the `payload`.
105109    /// Throw from this closure to indicate that authorization has failed.
106110    /// - Parameter callback: The callback to assign
@@ -176,18 +180,15 @@ public class Server<
176180                    let  stream  =  try await  onSubscribe ( graphQLRequest) 
177181                    for  try await  event  in  stream { 
178182                        try Task . checkCancellation ( ) 
179-                         do  { 
180-                             try await  self . sendData ( event,  id:  id) 
181-                         }  catch  { 
182-                             try await  self . sendError ( error,  id:  id) 
183-                             throw  error
184-                         } 
183+                         try await  self . sendData ( event,  id:  id) 
185184                    } 
186185                }  catch  { 
187186                    try await  sendError ( error,  id:  id) 
187+                     subscriptionTasks. removeValue ( forKey:  id) 
188188                    throw  error
189189                } 
190190                try await  self . sendComplete ( id:  id) 
191+                 subscriptionTasks. removeValue ( forKey:  id) 
191192            } 
192193        }  else  { 
193194            do  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments