fix: error instead of busy-looping when write returns Ok(0)#921
Merged
seanmonstar merged 1 commit intoJul 16, 2026
Merged
Conversation
This fixes a bug we saw in production. There's a nasty interaction between `h2` and the `ktls` crate. Namely: 1. When the write-side of the connection is closed, the `ktls` crate returns `Ok(0)` instead of an error. 2. `h2` retries `Ok(0)` writes, instead of treating them as errors. This led to busy looping, and 100% CPU utilization. Ideally, this should be fixed in both the `h2` and `ktls` crates, but I'm targeting `h2` first because of its central place in the ecosystem. This fix mirrors existing logic in hyper HTTP/1: https://github.com/hyperium/hyper/blob/v1.10.1/src/proto/h1/io.rs#L285-L297
seanmonstar
approved these changes
Jul 16, 2026
seanmonstar
left a comment
Member
There was a problem hiding this comment.
Oof. Makes sense to me, thanks for the fix!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a bug we saw in production. There's a nasty interaction between
h2and thektlscrate. Namely:ktlscrate returnsOk(0)instead of an error.h2retriesOk(0)writes, instead of treating them as errors.This led to busy looping, and 100% CPU utilization. Ideally, this should be fixed in both the
h2andktlscrates, but I'm targetingh2first because of its central place in the ecosystem.This fix mirrors existing logic in hyper HTTP/1: https://github.com/hyperium/hyper/blob/v1.10.1/src/proto/h1/io.rs#L285-L297