Closed
Description
Version 0.0.4 added a preconditionFailure()
to combineLatest
, merge
, zip
and debounce
that prevents iteration if the task is already cancelled.
The following pattern reproduces the issue in each of the operators:
let t = Task {
try? await Task.sleep(nanoseconds: 1_000_000_000)
let c1 = AsyncChannel<Int>()
let c2 = AsyncChannel<Int>()
for await (v1, v2) in combineLatest(c1, c2) {
print(v1, v2)
}
}
t.cancel()
The failure occurs within each operators version of func cancelled()
:
mutating func cancelled() -> CancelledAction? {
switch self.state {
case .initial:
preconditionFailure("Internal inconsistency current state \(self.state) and received cancelled()")
Is this intentional? The workaround is a tedious manual check before any iteration...
if !Task.isCancelled {
for await v1 in merge(c1, c2) {
print(v1)
}
}
Metadata
Metadata
Assignees
Labels
No labels