I have this weird example that crashes when the Zip is called.
The more weird issue is that changing the order of Zip parameters it works.
It seems that when the first future fails, Zip tries to cancels the second one, but it is already deallocated.
Is it a bug, or is there a catch?
enum Error: Swift.Error {
case error
}
let one = Future<String, Error> { promise in
promise(.failure(.error))
}
let two = Future<String, Error> { promise in
promise(.success("world"))
}
let cancelabel = Publishers.Zip(two, one).sink(receiveCompletion: {
print($0)
}, receiveValue: {
print($0)
})
print(cancelabel)
That seems like a bug. The zip should always retain both its dependent publishers (future or otherwise), and the sink should be retaining the zip. This should hold regardless of its completion state.