Here in your example:
swift
URLSession.shared
.dataTaskPublisher(for: URL(string: "https://www.apple.com/")!)
.tryCatch { _ in
URLSession.shared
.dataTaskPublisher(for: URL(string: "https://www.example.com/")!)
}
.retry(1)
.map {
String(decoding: $0.data, as: UTF8.self)
}
.sink(
receiveCompletion: { print("completed \($0)") },
receiveValue: { print("value \($0)") })
.store(in: &cancellables)
I see the leak of Combine.Publishers.Retry and Combine.Publishers.TryCatch
every time this code runs through the successful path. I've tried the failure path by changing apple.com to zapple.com - a non-existing domain, leak still appears.
Looks like retry is source of the leak and tryCatch is the cause of it.
When I remove retry or .tryCatch - no leaks. Is this a Combine bug or incorrect use of Combine?
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: