HTTP/2: respect closed-for-writing when streaming data frames #339
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found an odd scenario where a connection that is closed for writing will fail to
Mint.HTTP2.stream/2
any DATA frames that come in after the connection becomes read-only.I can attach the pcap if you'd like but since all that takes a bunch of work I've added a screenshot of the wireshark view of the scenario I found that triggers the behavior:
In this case a request opens up and sends some data. Then the server sends a GOAWAY (no error) that closes the connection for writing, and then it finishes out the request by sending the response HEADERS and a DATA frame (with the end stream flag). Mint parses that HEADERS into the appropriate
[{:headers, ref, headers}, {:status, ref, status}]
responses, but when it gets to handling the DATA frame (handle_data/3
) it gets into some trouble callingsend!/2
.It's using
send!/2
by callingrefill_client_windows/3
andclose_stream!/3
, which ends up in one of these throws:mint/lib/mint/http2.ex
Lines 2047 to 2051 in cf3ecab
So ultimately in this case
Mint.HTTP2.stream/2
returnsBut this PR changes the return for this case to
I'm starting with this PR as a draft as I try to figure out how to test this case 😅