Skip to content

Raise ConnectionNotAvailable instead of RemoteProtocolError on request with terminated HTTP/2 connections - #683

Closed
zanieb wants to merge 1 commit into
masterfrom
h2-closed-retry
Closed

Raise ConnectionNotAvailable instead of RemoteProtocolError on request with terminated HTTP/2 connections#683
zanieb wants to merge 1 commit into
masterfrom
h2-closed-retry

Conversation

@zanieb

@zaniebzanieb commented May 11, 2023

Copy link
Copy Markdown
Contributor

Follow-up to #679 (comment)

Attempts to improve handling of HTTP/2 behavior when connections are terminated.

Refs #730

Comment threadtests/_async/test_http2.py
@zanieb
zanieb marked this pull request as draft May 11, 2023 21:25
Base automatically changed from h2-closed to masterMay 12, 2023 12:54
@lovelydinosaur

Copy link
Copy Markdown
Contributor

If I was going to tackle this I would probably start with just the failing test case(s).

  • Changing the behaviour of the existing test, ensuring that ConnectionNotAvailable is raised instead of RemoteProtocolError.
  • Adding a test at the connection pool level - sending 2 requests with a mock connection that always sends GoAway after the first response, and ensuring that both requests succeed. (Because the second gracefully retries)

Comment on lines +148 to +153
if isinstance(
self._connection_error_event, h2.events.ConnectionTerminated
):
raise ConnectionNotAvailable(self._connection_error_event)
else:
raise RemoteProtocolError(self._connection_error_event)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this repeated isinstance check. We could move it into a utility or just always treat _connection_error_event as ConnectionNotAvailable instead of a protocol error.

@zanieb

Copy link
Copy Markdown
ContributorAuthor

Failing coverage checks now. I didn't add a test at the connection pool level yet. There are not HTTP/2 examples there, but it doesn't seem hard to add a mock stream as you suggested. Feel free to push changes.

@lovelydinosaurlovelydinosaur added the bug Something isn't working label Jun 14, 2023
@lovelydinosaur

Copy link
Copy Markdown
Contributor

I've added issue #730 so that we're tracking this neatly.

@lovelydinosaur

Copy link
Copy Markdown
Contributor

Thanks! Now superseeded by #733

@lovelydinosaur
lovelydinosaur deleted the h2-closed-retry branch June 16, 2023 18:14
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't working

Development

Successfully merging this pull request may close these issues.

2 participants

@zanieb@lovelydinosaur