Skip to content

[fix] h2 double complete#558

Merged
TingDaoK merged 2 commits into
mainfrom
double-complete
May 11, 2026
Merged

[fix] h2 double complete#558
TingDaoK merged 2 commits into
mainfrom
double-complete

Conversation

@TingDaoK
Copy link
Copy Markdown
Contributor

@TingDaoK TingDaoK commented May 8, 2026

Issue #, if available:

Description of changes:

  • In the case where the the remote sends GOAWAY marks the stream to be half closed, we will try to mark the stream complete, since we get a GOAWAY
  • Meanwhile, if user also want to cancel the stream and sending a RST_STREAM. Nothing prevents this, and spec also allows RST_STREAM to be sent after receiving GOAWAY. However, with sending RST_STREAM, we also try to mark the stream complete. And in which case, we complete the stream twice and everything blows up.
  • Add a simple boolean to prevent it from happening.

Arguably, we can prevent the RST_STREAM from a various places (User invoke, running the cross thread task ,etc..) But, sending it is not the real problem, and we do protect a lot around those when the connection/stream is shutting down. So, I chose to prevent the complete to happen again, so, every place can safely try to complete the stream regardless if it's already completed or not.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.68%. Comparing base (0409bc1) to head (618f5d8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #558   +/-   ##
=======================================
  Coverage   79.68%   79.68%           
=======================================
  Files          28       28           
  Lines       12082    12085    +3     
=======================================
+ Hits         9627     9630    +3     
  Misses       2455     2455           

☔ 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.

}

/* Test that cancelling a stream after GOAWAY does not crash from double stream completion.
* Reproduces P428540711: cancel() schedules cross-thread task, but s_finish_shutdown already
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we mention this magic number?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's a comment in the test, so pretty much for ourselves to reference.

@TingDaoK TingDaoK merged commit 2a22c94 into main May 11, 2026
46 checks passed
@TingDaoK TingDaoK deleted the double-complete branch May 11, 2026 16:16
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.

4 participants