Skip to content

h2 client: request pending stream open is dropped with DispatchGone when the connection closes #4269

Closed

Description

@P40b0s

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 task errors, 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

  1. added
    C-bug
    on Nov 14, 2026
  2. added a commit that references this issue on Nov 14, 2026
    95d6be7
  3. bunnysayzz commented on Nov 14, 2026

    @bunnysayzz
    Contributor

    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.

  4. bunnysayzz commented on Nov 14, 2026

    @bunnysayzz
    Contributor

    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.

  5. added a commit that references this issue on Nov 16, 2026
    dea9acb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions