Skip to content

Fix HTTP/2 error after response completion - #925

Closed
Alex-Wengg wants to merge 1 commit into
swift-server:mainfrom
Alex-Wengg:fix-http2-error-after-response-end
Closed

Alex-Wengg wants to merge 1 commit into
swift-server:mainfrom
Alex-Wengg:fix-http2-error-after-response-end

Conversation

@Alex-Wengg

Copy link
Copy Markdown

Motivation:

An HTTP/2 stream error can arrive after a response end has completed the request while its request body is still streaming. HTTP2ClientRequestHandler clears the request on response completion and then force-unwraps it while processing the later error, causing the crash reported in #922.

Modifications:

  • Only notify the request of failure when it is still present.
  • Preserve timeout cancellation and HTTP/2 stream cleanup for the late error.
  • Add a regression test for an error after response completion during a streaming upload.

Result:

Late HTTP/2 stream errors no longer crash the handler or fail an already-completed request.

Validation:

  • swift build
  • swift format lint --strict --configuration .swift-format on both changed files
  • The exact reproducer attached to Crash in HTTP2ClientRequestHandler #922, pointed at this checkout: receives 200 OK, completes normally, and exits 0 (unmodified 1.36.1 exits 133 at HTTP2ClientRequestHandler.swift:249).
  • The XCTest suite could not run locally because this Command Line Tools installation does not include the XCTest Swift module; CI will provide that coverage.

Fixes #922

Motivation:

An HTTP/2 stream error can arrive after a response end has completed the request while its request body is still streaming. The handler cleared the request on response completion and then force-unwrapped it while processing the later error, causing a crash.

Modifications:

Only fail the request when it is still present, while preserving timer and stream cleanup. Add a regression test for an error following a completed response during a streaming upload.

Result:

Late HTTP/2 stream errors no longer crash HTTP2ClientRequestHandler or fail an already-completed request.
@Alex-Wengg

Copy link
Copy Markdown
Author

Closing because I’m changing contribution focus. Thank you.

@Alex-Wengg Alex-Wengg closed this Sep 10, 2026
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