Skip to content

Commit 33bb29e

Browse files
committed
Fix cancel task outside, can't not trigger the close event.
1 parent 57454d7 commit 33bb29e

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

Sources/EventSource/EventSource.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,10 @@ public extension EventSource {
198198
}
199199
}
200200

201-
#if compiler(>=6.0)
202201
continuation.onTermination = { @Sendable [weak self] _ in
203202
sessionDelegateTask.cancel()
204-
Task { self?.close(stream: continuation, urlSession: urlSession) }
203+
self?.close(stream: continuation, urlSession: urlSession)
205204
}
206-
#else
207-
continuation.onTermination = { @Sendable _ in
208-
sessionDelegateTask.cancel()
209-
Task { [weak self] in
210-
await self?.close(stream: continuation, urlSession: urlSession)
211-
}
212-
}
213-
#endif
214205

215206
urlSessionDataTask.resume()
216207
readyState = .connecting

0 commit comments

Comments
 (0)