Skip to content

ResponseDataStream: ReaderStream vs .bytes #437

@johnbchron

Description

@johnbchron

Describe the bug
It looks like the AsyncRead implementation on ResponseDataStream is incorrect. The only datapoint I have at the moment is that I consistently only get about 1/3 the number of bytes back from reading all of tokio_util::io::ReaderStream::new(response_data_stream) vs response_data_stream.bytes.

Converting a impl Stream<Item<Result<bytes::Bytes, _>>> to a impl AsyncRead and then reading it should yield all the same bytes as just reading the stream directly, and I'm guessing it's not an issue with the ReaderStream implementation. I'll do some more testing.

To Reproduce

let req = bucket.get_object_stream(key).await.unwrap();
let stream = req.bytes;

let mut data = Vec::new();
while let Some(Ok(chunk)) = stream.next().await {
    data.extend(&chunk[..]);
}
println!("data.len() = {}", data.len());

// same as before, but now with:
let stream = tokio_util::io::ReaderStream::new(req);

Expected behavior
These two options produce the same number of bytes

Environment

  • Rust version: rustc 1.93.0-nightly (f37aa9955 2025-10-26)
  • lib version 0.37.0

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions