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.
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
Create memhttp package to debug flaky testcases #594
Create memhttp package to debug flaky testcases #594
Changes from 3 commits
4c43e4b
1f1df5d
225aa0d
27410bd
facfa53
877b4df
932533f
c057a62
f6a2bd7
40594b7
b9fccc6
dd98dd4
716794b
ccd39d4
91afa1e
ea743b3
628915a
23dc2da
2ee0def
00d7f6a
758f889
fa4a554
7b062d1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I've added these error checks to make
CloseResponse
behaviour more consistent. Otherwise Close does race with context cancel on errors causing either nil or a context error. Maybe we can revisit the discard behaviour in another PR.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.
Why is this changed? Since it was using
CloseWithError
and not simplyClose
, this would not be the source ofio.ErrPipeClosed
issues. In fact, I believe this will cause attempts to send on the broken stream to now returnio.ErrPipeClosed
instead ofio.EOF
.In order to control the error received by the write half (senders), you must close the read half (which is what it was doing before), and vice versa.
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.
Close
is just callingCloseWithError(nil)
which then gets set toio.EOF
: https://cs.opensource.google/go/go/+/refs/tags/go1.21.3:src/io/pipe.go;l=100It's always the opposite side of the pipe that gets the error with the current side getting:
io.ErrClosedPipe
.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.
SetError
called close on read:connect-go/duplex_http_call.go
Line 236 in d9b61e9
Was my mistake switching to
Writer
, it's now fixed in the latest PR.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.
Exactly. By closing the writer here, we will induce
io.ErrClosedPipe
in calls to send (which is what used the writer). The old behavior, closing the reader, is better since it results in EOF errors instead.I don't follow this. I'm looking at refreshed diff and it's still closing the writer.
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.
Sorry, I confused myself and switched the ordering. My previous comments don't align.
Closing the write side makes
Write
on the pipe error withio.ErrClosedPipe
. Connect checks for this when sending:connect-go/duplex_http_call.go
Line 106 in d9b61e9
However, on the read side we need to return
io.EOF
to avoid HTTP2 setting theio.ErrClosedPipe
as the error for the response body: #594 (comment)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.
CloseWrite
behaviour was different toSetError
:connect-go/duplex_http_call.go
Line 133 in d9b61e9
connect-go/duplex_http_call.go
Line 236 in d9b61e9
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.
Got it. Thank you for explaining!