-
Notifications
You must be signed in to change notification settings - Fork 125
Crash fix: HTTP2 can handle requests are cancelled #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash fix: HTTP2 can handle requests are cancelled #555
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, otherwise nice fix! Thanks!
XCTAssertNoThrow(request = try HTTPClient.Request(url: "https://localhost:\(bin.port)")) | ||
|
||
// just to establish an existing connection | ||
XCTAssertNoThrow(try client.execute(request: XCTUnwrap(request)).wait()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, nice use of XCTUnwrap inside a throwable auto closure!
@@ -193,11 +193,15 @@ final class HTTP2ClientRequestHandler: ChannelDuplexHandler { | |||
case .forwardResponseBodyParts(let parts): | |||
self.request!.receiveResponseBodyParts(parts) | |||
|
|||
case .failRequest(let error, let finalAction): | |||
case .failRequest(let error, _): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still use finalAction
elsewhere or can we remove it from the enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use it in the HTTP1ConnectionStateMachine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the reason for the comment starting in line 200.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sources/AsyncHTTPClient/ConnectionPool/HTTP2/HTTP2ClientRequestHandler.swift
Outdated
Show resolved
Hide resolved
Sources/AsyncHTTPClient/ConnectionPool/HTTPRequestStateMachine.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: George Barnett <[email protected]>
@swift-server-bot test this please |
5.6 and nightly failing because of Sendable requirements. |
Motivation
If a already cancelled request is scheduled on an existing HTTP/2 connection we currently run into a crash. This only happens if the request is scheduled on the same EventLoop as the HTTP/2 connection.
Changes
HTTPRequestStateMachine
resilient to failures before request start.Result