Replies: 1 comment 1 reply
-
@cwalo I think you and Brandon already discussed this on Slack, and I think the conclusion was that this is not a bug related to the lock, but a general behavior of Swift's async streams and suspension point thread hops. Since I don't think it's a bug in the library I'm going to convert to a discussion, but if it does turn out that there are improvements we could make, we'd be happy to address! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I stumbled on this issue after observing some missing values when using
eraseToStream()
. It seems that a side effect of introducing the lock is that values can be dropped if the sequence produces elements while the initializer is holding the lock. Assuming I'm holding everything correctly in the example below, the current implementation will drop the first few values pretty consistently. This is not the case when using the AsyncPublisher produced bypublisher.values
or when manually callingcontinuation.yield()
.I took a stab at this version which seems to be behave as expected and keeps things within the concurrency domain. That said, I'm not certain of the implications compared to the current implementation.
Leveraging the initializer with a bufferingPolicy:
Checklist
main
branch of this package.Expected behavior
All sequence elements are received.
Actual behavior
Sequence elements are sometimes missing.
Steps to reproduce
swift-concurrency-extras version information
1.1.0
Destination operating system
macOS 14.1.2
Xcode version information
15.0.1
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions