Skip to content

.buffered(0).next().await hangs indefinitely #2981

@nameexhaustion

Description

@nameexhaustion

Reproducible example

#[test]
fn test() {
    use futures::StreamExt;
    tokio::runtime::Builder::new_current_thread()
        .enable_all()
        .build()
        .unwrap()
        .block_on(async {
            futures::stream::iter(0..10)
                .map(|x| std::future::ready(x))
                .buffered(0)
                .next()
                .await
                .unwrap();
        })
}

I don't think the current behavior (silently hanging) is ideal, but I'm also not sure of a better alternative - I can think of a few options -

  • Take NonZeroUsize (or TryInto<NonZeroUsize> in the API
  • Internally clamp n to be a minimum of 1
  • Return None for next()
  • Panic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions