Fix HTTP/1 active-request metric lifecycle when connection closes before request body completes - #6336
Open
tsegismont wants to merge 1 commit into
Open
Fix HTTP/1 active-request metric lifecycle when connection closes before request body completes#6336tsegismont wants to merge 1 commit into
tsegismont wants to merge 1 commit into
Conversation
vietj
reviewed
Aug 28, 2026
…ore request body completes When the server sends an early response before the request body is fully received and the client then closes the connection, responseEnd() is already called by reportResponseComplete() at response-write time. The additional requestReset() call in handleClosed() violates the SPI contract of exactly one terminal call per request. Fix handleClosed() by delegating to requestInProgress.handleException() behind a requestInProgress.response != null guard, which skips pipelined requests where handleBegin() was never called (avoiding a null metric NPE) and relies on the existing !response.ended() check to prevent a double terminal call. Apply the same response != null guard to handleException() to prevent the equivalent NPE under IO errors. Add two regression tests using Vert.x NetClient: one verifying that responseEnd is the terminal call when an early 401 is sent and the client closes before delivering the body; one verifying that requestReset is the terminal call when the client closes before the body with no response sent. Assisted-by: Anthropic Claude (claude-sonnet-4-6) Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
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.
When the server sends an early response before the request body is fully received and the client then closes the connection, responseEnd() is already called by reportResponseComplete() at response-write time. The additional requestReset() call in handleClosed() violates the SPI contract of exactly one terminal call per request.
Fix handleClosed() by delegating to requestInProgress.handleException() behind a requestInProgress.response != null guard, which skips pipelined requests where handleBegin() was never called (avoiding a null metric NPE) and relies on the existing !response.ended() check to prevent a double terminal call.
Apply the same response != null guard to handleException() to prevent the equivalent NPE under IO errors.
Add two regression tests using Vert.x NetClient: one verifying that responseEnd is the terminal call when an early 401 is sent and the client closes before delivering the body; one verifying that requestReset is the terminal call when the client closes before the body with no response sent.
Assisted-by: Anthropic Claude (claude-sonnet-4-6)