Skip to content

fix(http2): tolerate stream errors after response completion - #933

Open
rupayon123 wants to merge 1 commit into
swift-server:mainfrom
rupayon123:fix/922-http2-error-after-response-end
Open

rupayon123 wants to merge 1 commit into
swift-server:mainfrom
rupayon123:fix/922-http2-error-after-response-end

Conversation

@rupayon123

Copy link
Copy Markdown

Summary

Fixes #922. When a streaming request has already delivered its response end, a later HTTP/2 stream error can reach failRequest after the handler cleared its request. The handler now safely skips the second request failure while still closing the HTTP/2 channel and clearing timeout state.

Reproduction and validation

  • Reproduced the attached localhost-only HTTP/2 reset scenario against the unmodified upstream checkout; it crashed at the force unwrap in HTTP2ClientRequestHandler.
  • The same attached reproduction completed normally against this branch.
  • Added an EmbeddedChannel regression for a streamed request, successful response end, then a later stream error.
  • swift test --filter HTTP2ClientRequestHandlerTests/testErrorAfterResponseEndWhileRequestBodyIsStreamingDoesNotCrash passed.
  • swift test --filter HTTP2ClientRequestHandlerTests passed.
  • swift format lint --strict --configuration .swift-format ... and git diff --check passed.

The attached end-to-end reproducer uses a localhost test certificate and does not contact an external host. The unit test verifies handler state and channel closure; it does not replace the end-to-end reproduction.

AI assistance: OpenAI Codex assisted with the investigation and draft. I reviewed the diff and ran the checks listed above.

When a response ends before a streamed request body finishes, the handler clears its request. A later stream error must still close the HTTP/2 channel without force-unwrapping that completed request.

Add a deterministic EmbeddedChannel regression for response-end then stream-error ordering.

This branch has not been deployed

No deployments
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.

Crash in HTTP2ClientRequestHandler

1 participant