Skip to content

fix(binding-http): reset streaming response on remote client disconnect - #1850

Merged
jfallows merged 2 commits into
developfrom
fix/binding-http-streaming-reset
Jun 8, 2026
Merged

jfallows merged 2 commits into
developfrom
fix/binding-http-streaming-reset

Conversation

@jfallows

@jfallows jfallows commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Problem

For an HTTP/1.1 server exchange whose request is already complete but whose response is still streaming (e.g. Server-Sent Events), a graceful client disconnect arrives as a network END. HttpExchange.onNetworkEnd only aborted the request and left the open response untouched, so the application's response stream was never reset and was only reaped later by the inactivity timeout. This is inconsistent with HTTP/2, which resets the reply on END via cleanup.

Change

  • When the response is OPEN on network END, reset it and abort the network reply, mirroring the existing onDecodeBodyInvalid path. The responseState == OPEN guard preserves the valid HTTP half-close case (client closes its request side then reads the full response), which still completes via the existing replyCloseOnFlush path.
  • Add server IT rfc7230 .../client.close.during.response: a streaming response is reset (write aborted) when the client closes the connection mid-response.
  • Add the matching rfc7540 (HTTP/2) scenario to lock in parity — HTTP/2 already handles this via Http2Server cleanup on network END; the test pins the behavior.

Verification

./mvnw clean verify -pl runtime/binding-http is green. The new shouldResetResponseWhenClientClosesDuringResponse runs in both the rfc7230 and rfc7540 server ConnectionManagementITs; all four ConnectionManagementIT classes pass.

🤖 Generated with Claude Code

jfallows and others added 2 commits June 7, 2026 19:08
For an HTTP/1.1 server exchange whose request is already complete but whose
response is still streaming (e.g. Server-Sent Events), a graceful client
disconnect arrives as a network END. HttpExchange.onNetworkEnd only aborted
the request and left the open response untouched, so the application's
response stream was never reset and was only reaped by inactivity. This is
inconsistent with HTTP/2, which resets the reply on END via cleanup.

When the response is OPEN on network END, reset it and abort the network
reply, mirroring the existing onDecodeBodyInvalid path. The responseState
== OPEN guard preserves the valid HTTP half-close case (client closes its
request side then reads the full response), which completes via the existing
replyCloseOnFlush path.

Add server IT client.close.during.response: a streaming response is reset
(write aborted) when the client closes the connection mid-response.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…t close

Mirror the rfc7230 client.close.during.response scenario for HTTP/2: a server
exchange whose request is complete but whose response is still streaming is
reset (write aborted) when the client closes the connection mid-response.
HTTP/2 already handles this via Http2Server cleanup on network END; this locks
in parity with the HTTP/1.1 fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@jfallows jfallows left a comment

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.

LGTM

@jfallows
jfallows merged commit 2bed30f into develop Jun 8, 2026
73 of 74 checks passed
@jfallows jfallows self-assigned this Jun 8, 2026
@jfallows
jfallows deleted the fix/binding-http-streaming-reset branch July 1, 2026 23:04
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.

1 participant