Skip to content

H2Upgraded::poll_write returns Ok(0) while tokio-rustls assumes Ok(0) is 'successful' #3801

Closed
@hatoo

Description

@hatoo

Version
List the version(s) of hyper, and any relevant hyper dependency (such as h2 if this is related to HTTP/2).
hyper: commit 12717d1

Platform
The output of uname -a (UNIX), or version and 32 or 64-bit (Windows)

WSL2 Ubuntu on Windows 11

❯ uname -a
Linux WindowsNVMe 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Description

When we wrap tokio-rustls around HTTP2 Upgraded stream, tokio-rustls will infinite loop because Upgraded stream returns Ok(0) on poll_write when shutdown. relevant issue rustls/tokio-rustls#92

hyper/src/proto/h2/mod.rs

Lines 329 to 337 in 12717d1

let cnt = match ready!(self.send_stream.poll_capacity(cx)) {
None => Some(0),
Some(Ok(cnt)) => self
.send_stream
.write(&buf[..cnt], false)
.ok()
.map(|()| cnt),
Some(Err(_)) => None,
};

I've found that when I replace None => Some(0), to None => None, it works fine.

Honestly, I don't know the issue should be resolved in either hyper or tokio-rustls. But this issue is important when I implement HTTP2 proxy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug. Something is wrong. This is bad!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions