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<
101
101
}
102
102
}
103
103
104
+ deinit {
105
+ subscriptionTasks. values. forEach { $0. cancel ( ) }
106
+ }
107
+
104
108
/// Define a custom callback run during `connection_init` resolution that allows authorization using the `payload`.
105
109
/// Throw from this closure to indicate that authorization has failed.
106
110
/// - Parameter callback: The callback to assign
@@ -176,18 +180,15 @@ public class Server<
176
180
let stream = try await onSubscribe ( graphQLRequest)
177
181
for try await event in stream {
178
182
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)
185
184
}
186
185
} catch {
187
186
try await sendError ( error, id: id)
187
+ subscriptionTasks. removeValue ( forKey: id)
188
188
throw error
189
189
}
190
190
try await self . sendComplete ( id: id)
191
+ subscriptionTasks. removeValue ( forKey: id)
191
192
}
192
193
} else {
193
194
do {
You can’t perform that action at this time.
0 commit comments