Skip to content

Conversation

gschulze
Copy link

@gschulze gschulze commented Aug 16, 2024

PR Type

Bug Fix

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

Currently, if there is an error during an HTTP request, the message body is not completely consumed in actix-web/src/types/payload.rs. In cases where HTTP keep-alive is enabled, this causes the connection to hang in the CLOSE-WAIT state, with the TCP receive queue still containing some bytes that need to be consumed. This PR modifies the Future implementation for HttpMessageBody to always consume all available data and return with success or error at the end. Besides issue #3182, there might be similar issues that are resolved by this PR.

Closes #3182

@gschulze gschulze force-pushed the bugfix/always-consume-message-body branch 2 times, most recently from 2181642 to b498c65 Compare August 16, 2024 18:29
@gschulze gschulze force-pushed the bugfix/always-consume-message-body branch from b498c65 to 7da7390 Compare September 1, 2024 11:57
@gschulze
Copy link
Author

gschulze commented Sep 6, 2024

Hey @robjtede, what are your thoughts on this?

@JohnTitor
Copy link
Member

I've tried your patch on my local, but the issue remains. Please check again that the fix is actually valid, and add a regression test for this case somehow (I know it's challenging, though).

@gschulze
Copy link
Author

@JohnTitor I remember having a thorough test setup one year ago when I investigated the issue. I need to check whether I can find the code from back then.

@robjtede robjtede added B-semver-patch A-web project: actix-web labels Aug 29, 2025
@robjtede
Copy link
Member

robjtede commented Aug 29, 2025

i think the issue is related to #3715 where we've discussed and are testing a fix at the actix-http level, i think that supersedes this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web B-semver-patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connections hang in CLOSE-WAIT state
3 participants