Skip to content

Commit

Permalink
next() can get stuck if task is already cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Oct 25, 2022
1 parent ee170c2 commit ef832b5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Sources/Operators/AsyncSwitchToLatestSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ where Base.Element: AsyncSequence, Base: Sendable, Base.Element.Element: Sendabl
}

public mutating func next() async rethrows -> Element? {
guard !Task.isCancelled else { return nil }
self.startBase()

return try await withTaskCancellationHandler { [baseTask] in
Expand Down

0 comments on commit ef832b5

Please sign in to comment.