@@ -204,37 +204,26 @@ extension ValkeyConnection {
204
204
) async throws -> ( Int , ValkeySubscription ) {
205
205
let requestID = Self . requestIDGenerator. next ( )
206
206
let ( stream, streamContinuation) = ValkeySubscription . makeStream ( )
207
- return try await withTaskCancellationHandler {
208
- if Task . isCancelled {
209
- throw ValkeyClientError ( . cancelled)
210
- }
211
- let subscriptionID : Int = try await withCheckedThrowingContinuation { continuation in
212
- self . channelHandler. subscribe (
213
- command: command,
214
- streamContinuation: streamContinuation,
215
- filters: filters,
216
- promise: . swift( continuation) ,
217
- requestID: requestID
218
- )
219
- }
220
- return ( subscriptionID, stream)
221
- } onCancel: {
222
- self . cancel ( requestID: requestID)
207
+ if Task . isCancelled {
208
+ throw ValkeyClientError ( . cancelled)
223
209
}
210
+ let subscriptionID : Int = try await withCheckedThrowingContinuation { continuation in
211
+ self . channelHandler. subscribe (
212
+ command: command,
213
+ streamContinuation: streamContinuation,
214
+ filters: filters,
215
+ promise: . swift( continuation) ,
216
+ requestID: requestID
217
+ )
218
+ }
219
+ return ( subscriptionID, stream)
224
220
}
225
221
226
222
@usableFromInline
227
223
func unsubscribe( id: Int ) async throws {
228
224
let requestID = Self . requestIDGenerator. next ( )
229
- try await withTaskCancellationHandler {
230
- if Task . isCancelled {
231
- throw ValkeyClientError ( . cancelled)
232
- }
233
- try await withCheckedThrowingContinuation { continuation in
234
- self . channelHandler. unsubscribe ( id: id, promise: . swift( continuation) , requestID: requestID)
235
- }
236
- } onCancel: {
237
- self . cancel ( requestID: requestID)
225
+ try await withCheckedThrowingContinuation { continuation in
226
+ self . channelHandler. unsubscribe ( id: id, promise: . swift( continuation) , requestID: requestID)
238
227
}
239
228
}
240
229
0 commit comments