Repository navigation
Description
Human words
- The words are written by a human.
Version
1.12.0
Platform
Linux fedora 7.2.15-200.fc44.x86_64
Summary
When an HTTP/2 request is waiting for a stream slot (SendRequest::poll_ready returned Pending after send_request because of SETTINGS_MAX_CONCURRENT_STREAMS), ClientTask keeps it in self.fut_ctx. If the connection then fails or is shut down by the peer (GOAWAY), the next ClientTask::poll returns early from the top-of-loop poll_ready check:
// src/proto/h2/client.rs, ClientTask::poll
match ready!(self.h2_tx.poll_ready(cx)) {
Ok(()) => (),
Err(err) => {
self.ping.ensure_not_timed_out()?;
return if err.reason() == Some(::h2::Reason::NO_ERROR) {
Poll::Ready(Ok(Dispatched::Shutdown))
} else {
Poll::Ready(Err(crate::Error::new_h2(err)))
};
}
}
// only reached on Ok:
if let Some(f) = self.fut_ctx.take() { ... }
self.fut_ctx is never taken on this path, and neither FutCtx nor ClientTask implements Drop. So the Callback stored in FutCtx gets dropped without a response, and Callback::drop reports:
hyper::Error(User(DispatchGone), "runtime dropped the dispatch task")
The runtime is still alive, so this message is misleading. The caller also sees a user error rather than a connection/canceled error, so higher layers do not treat it as retryable even though the request never reached the server. For example, the AWS SDK classifies it as ConnectorError { kind: User } and does not retry.
How to hit it
AWS SDK for Rust (aws-smithy-http-client 1.5, hyper-util legacy client, ALPN h2) against an S3 endpoint behind nginx. Under bursts of concurrent HEAD/GET requests we see:
- occasional bursts of
REFUSED_STREAM(so we do reach the stream limit); - sporadic single
DispatchGone: runtime dropped the dispatch taskerrors, which we believe are the server sending GOAWAY while a request is pending open.
All tasks run in a long-lived multi-thread runtime that is never shut down, and no thread panics, so the runtime-shutdown explanation does not apply.
Code Sample
Expected Behavior
The pending request's callback should get an error: the h2 error/reason, or canceled("connection closed") as Envelope::drop does for queued requests, so callers can tell it was not sent and retry.
Actual Behavior
When an HTTP/2 request is waiting for a stream slot (SendRequest::poll_ready returned Pending after send_request because of SETTINGS_MAX_CONCURRENT_STREAMS), ClientTask keeps it in self.fut_ctx. If the connection then fails or is shut down by the peer (GOAWAY), the next ClientTask::poll returns early from the top-of-loop poll_ready check. self.fut_ctx is never taken on this path, and neither FutCtx nor ClientTask implements Drop. So the Callback stored in FutCtx gets dropped without a response, and Callback::drop reports:
hyper::Error(User(DispatchGone), "runtime dropped the dispatch task")
The runtime is still alive, so this message is misleading. The caller also sees a user error rather than a connection/canceled error, so higher layers do not treat it as retryable even though the request never reached the server. For example, the AWS SDK classifies it as ConnectorError { kind: User } and does not retry.
Additional Context
No response
Activity
fix(client): fail parked h2 request with connection error on close
bunnysayzz commentedon Nov 14, 2026
Hit this while looking at the h2 client. When the connection drops with a request still parked waiting for a stream slot, the parked callback just falls through to drop and the caller gets a misleading DispatchGone user error. I have a fix plus a regression test, PR coming up.
bunnysayzz commentedon Nov 14, 2026
PR is up: #4275
Root cause: in ClientTask::poll, the poll_ready error branch returns without failing the parked callback, so a request waiting for a stream slot falls through to Callback::drop and the caller sees DispatchGone. The fix fails the parked callback there instead, canceled on a clean GOAWAY, the h2 reason otherwise, and keeps returning the original error from the task.
Regression test uses a server that allows one concurrent stream and closes while the second request is parked. It fails before the fix with User(DispatchGone) and passes after.
fix(client): fail parked h2 request with connection error on close (h…