iawia002 opened issue #9653:
My scenario is simple: I want to send a request with a large body, but the
blocking_write_and_flush
method can only write 4096 bytes at a time. Naturally, I decided to call this method multiple times to write the entire body:let req = OutgoingRequest::new(...); let outgoing_body = req.body().unwarp(); let request_body = outgoing_body.write().unwarp(); let chunks = buf.chunks(4096); for chunk in chunks { request_body.blocking_write_and_flush(chunk).expect("writing response"); } OutgoingBody::finish(outgoing_body, None).unwarp();
However, I found that the program gets stuck forever on the second call to
blocking_write_and_flush
. After debugging, I found that it actually gets stuck during theready
check in the second call:At this point, the writer has no capacity left, but my writing process hasn't finished, so the reader hasn't started consuming the data (?).
For my issue, I could stop using this method and instead combine
check-write
,subscribe
,write
, andflush
manually to solve it. However, I'm curious whether we are inclined to allow or not allow this behavior. Because the current behavior is strange—the program doesn't report an error, it just hangs indefinitely.
Last updated: Nov 22 2024 at 16:03 UTC