Skip to content

buffer_unordered footgun: 0 futures #2939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BatmanAoD opened this issue Apr 4, 2025 · 1 comment
Closed

buffer_unordered footgun: 0 futures #2939

BatmanAoD opened this issue Apr 4, 2025 · 1 comment

Comments

@BatmanAoD
Copy link
Member

If n=0 for StreamExt::buffer_unordered(n), then waiting for the stream to complete simply hangs, even if the stream itself is empty. This is a footgun (we ran into it when using len() as the argument to buffer_unordered).

As a breaking change, n could be of type NonZeroUsize instead of usize. As a non-breaking change, would it be possible to make the future complete immediately in the case where the actual underlying stream is empty?

@taiki-e
Copy link
Member

taiki-e commented Apr 5, 2025

Duplicate of #2348, #2740, #2876, etc.

Already fixed in 0.4 (master branch).

AFAIK, the hang here is not an actual hang of the method, but due to the returned future always returning Pending and you only waiting for that future. users of APIs such as select may depend on that behavior, so if we do it in 0.3 as a non-breaking change, it may cause another problem.

@taiki-e taiki-e closed this as completed Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants