Skip to content

Do not send CONNECTION_CLOSE frames in draining state#5477

Merged
guhetier merged 1 commit intomainfrom
guhetier/fix_draining_state
Oct 3, 2025
Merged

Do not send CONNECTION_CLOSE frames in draining state#5477
guhetier merged 1 commit intomainfrom
guhetier/fix_draining_state

Conversation

@guhetier
Copy link
Collaborator

@guhetier guhetier commented Oct 2, 2025

Description

Some spurious test failures show a pattern when the two peers entered a loop of sending CONNECTION_CLOSE frames to each other. This regression was introduced by #5107.

According to RFC 9000:

  • When a peer sends a CONNECTION_CLOSE frame, it enters the "closing" state and should answer any incoming packet on the connection with a new CONNECTION_CLOSE frame (subject to rate limiting), to ensure the peer get the CONNECTION_CLOSE.
  • When a peer receives a CONNECTION_CLOSE frame, it enters the "draining" state and should not send any more packets.

(The RFC is not explicit about what happens when a peer in the "closing" state receives a CONNECTION_CLOSE, but since it means both peers are closing the connection, it can stop sending additional CONNECTION_CLOSE).

However, #5107 was re-sending CONNECTION_CLOSE frame both in "closing" and "draining" state. This PR fixes it.

Testing

CI. The issue is timing dependent and can't be reliably reproduced.

Documentation

N/A

@guhetier guhetier marked this pull request as ready for review October 2, 2025 16:16
@guhetier guhetier requested a review from a team as a code owner October 2, 2025 16:16
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.70%. Comparing base (21071b9) to head (aeade43).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5477      +/-   ##
==========================================
- Coverage   85.45%   84.70%   -0.76%     
==========================================
  Files          59       59              
  Lines       18620    18621       +1     
==========================================
- Hits        15912    15773     -139     
- Misses       2708     2848     +140     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@guhetier guhetier merged commit 522c86a into main Oct 3, 2025
465 of 466 checks passed
@guhetier guhetier deleted the guhetier/fix_draining_state branch October 3, 2025 20:44
guhetier added a commit that referenced this pull request Oct 6, 2025
guhetier added a commit that referenced this pull request Oct 6, 2025
guhetier added a commit that referenced this pull request Oct 7, 2025
Copilot AI pushed a commit that referenced this pull request Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants