rust-lang / futures-rs

Zero-cost asynchronous programming in Rust
https://rust-lang.github.io/futures-rs/
Apache License 2.0
5.34k stars 616 forks source link

nested flatten_unordered hangs #2725

Closed krallin closed 1 year ago

krallin commented 1 year ago

I've (also) run into this issue that was reported on users.rust-lang.

I suspect this might be the right forum to contact the maintainers of the futures crate, so here's an issue as well and a cleaned up repro. Namely, this hangs:

#[tokio::main]
async fn main() {
    use futures::future;
    use futures::stream;
    use futures::StreamExt;
    use tokio::time::interval;
    use tokio_stream::wrappers::IntervalStream;

    let inner = IntervalStream::new(interval(std::time::Duration::from_millis(500)))
        .map(|_| stream::once(future::ready("VALUE")))
        .flatten_unordered(None);

    let mut stream = stream::once(future::ready(inner)).flatten_unordered(None);

    while let Some(value) = stream.next().await {
        dbg!(&value);
    }
}

This seems like it should evidently just yield values forever (by creating a new stream-of-1-value every 500ms), but as-is it does not and it just hangs after the first value.

krallin commented 1 year ago

@olegnn, @taiki-e : quick question: when might we expect a release containing those bugfixes?

taiki-e commented 1 year ago

Published in 0.3.28.