-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Missing error when reading stream of data out of an interrupted chunked-encoded request #3253
Comments
I've been playing around with the demo on my own machine, and even without the timeout, I see what you're describing. When I turn on tracing, I see that the connection task encounters a write error, because the socket is closed, and then that closes up the task. I would guess that it depends on what exact option the connection task is doing when you kill the curl process: if it was trying to read, it will see a read error, if it was trying to write, it will log it and close up. So, I'd say that at least the problem is that when the connection task is closing, the request body sender (the internal side giving you the request body bytes) doesn't notice it should send a final error item. |
My problem domain is storage systems, and when user uploads a file of unknown length (via chunked encoding) it is really important to get reliable information on how stream has ended. With current state of things, drop of the client might result in new object being successfully uploaded to storage system with only partial content. |
I've got a fix pending in #3256, I'll backport it to 0.14 after it's good in master. |
If a connection has any error besides reading, a streaming body sometimes wouldn't be notified. This change makes it so that when a connection task is closing because of any error, an existing body channel is also notified. Closes #3253
If a connection has any error besides reading, a streaming body sometimes wouldn't be notified. This change makes it so that when a connection task is closing because of any error, an existing body channel is also notified. Closes #3253
If a connection has any error besides reading, a streaming body sometimes wouldn't be notified. This change makes it so that when a connection task is closing because of any error, an existing body channel is also notified. Closes #3253
Thanks for quick turnaround @seanmonstar ! |
If a connection has any error besides reading, a streaming body sometimes wouldn't be notified. This change makes it so that when a connection task is closing because of any error, an existing body channel is also notified. Closes #3253
Includes a lightly-modified version of hyper-util's `TokioIo` utility. Hyper changes: v1.0.0-rc.4 (2023-07-10) Bug Fixes http1: http1 server graceful shutdown fix (#3261) ([f4b51300](hyperium/hyper@f4b5130)) send error on Incoming body when connection errors (#3256) ([52f19259](hyperium/hyper@52f1925), closes hyperium/hyper#3253) properly end chunked bodies when it was known to be empty (#3254) ([fec64cf0](hyperium/hyper@fec64cf), closes hyperium/hyper#3252) Features client: Make clients able to use non-Send executor (#3184) ([d977f209](hyperium/hyper@d977f20), closes hyperium/hyper#3017) rt: replace IO traits with hyper::rt ones (#3230) ([f9f65b7a](hyperium/hyper@f9f65b7), closes hyperium/hyper#3110) add downcast on Sleep trait (#3125) ([d92d3917](hyperium/hyper@d92d391), closes hyperium/hyper#3027) service: change Service::call to take &self (#3223) ([d894439e](hyperium/hyper@d894439), closes hyperium/hyper#3040) Breaking Changes Any IO transport type provided must not implement hyper::rt::{Read, Write} instead of tokio::io traits. You can grab a helper type from hyper-util to wrap Tokio types, or implement the traits yourself, if it's a custom type. ([f9f65b7a](hyperium/hyper@f9f65b7)) client::conn::http2 types now use another generic for an Executor. Code that names Connection needs to include the additional generic parameter. ([d977f209](hyperium/hyper@d977f20)) The Service::call function no longer takes a mutable reference to self. The FnMut trait bound on the service::util::service_fn function and the trait bound on the impl for the ServiceFn struct were changed from FnMut to Fn.
…ium#3256) If a connection has any error besides reading, a streaming body sometimes wouldn't be notified. This change makes it so that when a connection task is closing because of any error, an existing body channel is also notified. Closes hyperium#3253
…ium#3256) If a connection has any error besides reading, a streaming body sometimes wouldn't be notified. This change makes it so that when a connection task is closing because of any error, an existing body channel is also notified. Closes hyperium#3253 Signed-off-by: Sven Pfennig <[email protected]>
Version
hyper 0.14.26
tokio 1.28.1
Platform
Linux my-hostname 5.10.0-18-amd64 #1 SMP Debian 5.10.140-1 (2022-09-02) x86_64 GNU/Linux
Description
Error is not propagated via stream in some cases when client drops the connection during chunked-encoding stream.
I tried this code:
Cargo.toml dependencies:
Service above is an echo-server, which sends back the stream of data that it receives. To get the repro, please launch the service, and on another terminal start the "endless" curl command like this:
It will read
/dev/zero
, pipe it to curl, which will send it as data stream with chunked transfer encoding, sending the output stream to/dev/null
.After some time, terminate curl with
Ctrl+C
. Service reports the error on the stream as expected, terminal output will look like this:But if we uncomment the sleep line, and repeat the experiment, there will be no error, as indicated by service output:
I'm observing this weird behavior on a larger codebase that does approximately the same as sample server presented above.
One more interesting observation, even when sleep is in place, it does not repro (i.e. error is reported properly) with this netcat:
My larger codebase also works as expected with netcat. Is there a race somewhere?
The text was updated successfully, but these errors were encountered: