-
Notifications
You must be signed in to change notification settings - Fork 33
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
Stream merge
function calls poll_next
again after returning Poll::Ready(None)
#120
Comments
Oops, that's not good. I believe you already reported this a while back, so I apologize for the regression. Let's fix this ASAP. |
Okay, so I'm trying to repro it on the main branch, and the following test seems to pass without any problem: #[test]
fn main() {
block_on(async {
let create_stream = |count| {
futures::stream::unfold(count, |n| async move {
if n > 1 {
Some((n, n - 1))
} else {
None
}
})
};
let stream_1 = create_stream(10);
let stream_2 = create_stream(10);
let merged = (stream_1, stream_2).merge();
futures::StreamExt::collect::<Vec<_>>(merged).await;
// merged.collect::<Vec<_>>().await;
})
} I tried replacing |
Ah, I used the latest crates.io release, |
I tried to pinpoint the commit and it looks like #96 fixed the issue. |
Okay! -- Seems like the right thing to do is then to publish a new release. On it! |
Perfect, thanks a lot! |
The
Stream::poll_next
should not be called again after it returnedReady(None)
, otherwise it "may panic, block forever, or cause other kinds of problems". Themerge
implementation does not seem to respect this.For example, the following code will panic:
The panic message is:
Fusing the streams (i.e.
create_stream(10).fuse()
) fixes this, but this should not be needed, or enforced by the API.The text was updated successfully, but these errors were encountered: