Skip to content
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

Forward all reads before stream channel inactive #317

Merged

Conversation

fabianfett
Copy link
Member

Motivation

In the AsyncHTTPClient the read event is not always forwarded right away. We have seen instances, in which we see a HTTPClientError.remoteConnectionClosed error, on requests that finish normally. swift-server/async-http-client#488

On deeper inspection, I noticed: If there is no unsatisfied read event, when a stream is closed, the pending reads are not forwarded. This can lead to response bytes being ignored on successful requests. NIOHTTP2 should behave as NIO and force forward all pending reads on channelInactive.

Changes

  • Forward all pending reads on channelInactive even if no read event has hit the channel

Result

All requests will receive the complete request body.

@fabianfett fabianfett requested a review from Lukasa November 30, 2021 15:40
@fabianfett fabianfett added the 🔨 semver/patch No public API change. label Nov 30, 2021
@fabianfett fabianfett requested a review from dnadoba November 30, 2021 15:44
@fabianfett fabianfett changed the title Forward all reads before channel inactive Forward all reads before stream channel inactive Nov 30, 2021
Copy link
Contributor

@Lukasa Lukasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor nit, otherwise LGTM.

Sources/NIOHTTP2/HTTP2StreamChannel.swift Outdated Show resolved Hide resolved
Co-authored-by: Cory Benfield <lukasa@apple.com>
@fabianfett fabianfett merged commit 39ed0e7 into apple:main Nov 30, 2021
@fabianfett fabianfett deleted the ff-forward-all-reads-before-channelInactive branch November 30, 2021 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants