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 authored and twittemb committed Jan 3, 2023
1 parent 1286bef commit 2f596e1
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 2f596e1

Please sign in to comment.