swift-async-algorithms: A throttled `AsyncSequence` doesn't yield its parent sequence's final value
Not sure if this is expected behavior.
I make an AsyncStream called stream, and a throttled sequence from that stream throttledStream. I yield values into stream for a while, and eventually call finish() on its continuation. All the while in the background I am iterating through throttledStream - when finish() gets called on stream, my iteration through throttledStream finishes, but I don’t get the final value that was sent to stream.
Sorry this is kind of a complicated way to explain the issue, but I will make a reproducible example project if this behavior sounds like it is indeed not intended!
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 24 (14 by maintainers)
Commits related to this issue
- Make throttle `internal` # Motivation During the discussion in https://github.com/apple/swift-async-algorithms/issues/248 it became clear that the semantics of `throttle` are not 100% figured out yet... — committed to FranzBusch/swift-async-algorithms by FranzBusch 9 months ago
- Make throttle underscored # Motivation During the discussion in https://github.com/apple/swift-async-algorithms/issues/248 it became clear that the semantics of `throttle` are not 100% figured out ye... — committed to FranzBusch/swift-async-algorithms by FranzBusch 9 months ago
- Make throttle underscored # Motivation During the discussion in https://github.com/apple/swift-async-algorithms/issues/248 it became clear that the semantics of `throttle` are not 100% figured out ye... — committed to FranzBusch/swift-async-algorithms by FranzBusch 9 months ago
- Make throttle underscored (#296) # Motivation During the discussion in https://github.com/apple/swift-async-algorithms/issues/248 it became clear that the semantics of `throttle` are not 100% figure... — committed to apple/swift-async-algorithms by FranzBusch 9 months ago
Combine for example used the rule for throttle and debounce: that the iterative output (not the signals to determine failure or finishedness) are the rate limited things. So specifically for throttle; it means that even the last value should not emit any faster than the requested throttling rate.
The intent for folks using throttle is that they don’t ever want a rate beyond a given value. Making the last value ignore that would break folks expectations.
We can definitely have a
latest: trueoption here. The implementation should also be quite trivial, if we getnilfrom the upstream and we have alastvalue andlatest = truethen we can do aTask.sleepuntil the timeout has passed.If that happens and you can reproduce it please open a separate issue here.