Preserve debounce upstream failure without outstanding demand (#451)

* Preserve debounce upstream failure without demand

* Add debounce upstream failure regression tests
This commit is contained in:
Hokila Jan authored and GitHub committed 2026-10-05 16:11:40 +02:00
1 parent d9c26817af
commit cbde9aed74
2 files changed
+73 -3

No files matched your search

@@ -399,9 +399,9 @@ struct DebounceStateMachine<Base: AsyncSequence & Sendable, C: Clock>: Sendable
return .none
case .waitingForDemand(let task, .none, let clockContinuation, .none):
// We don't have any buffered element so we can just go ahead
// and transition to finished and cancel everything
self.state = .finished
// We don't have outstanding demand to deliver the error to, so store it
// until the downstream calls next and cancel everything.
self.state = .upstreamFailure(error: error)
return .cancelTaskAndClockContinuation(
task: task,