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.
When you shutdown the connection and we close the reader, a surprising
thing happens under certain conditions: the read loop wakes up, asks for
the next read operation, and is told to yield. It tries to yield, and
then the state machine raises -- you shouldn't be yielding if the
connection is closed!
The reason for this is our explicit return of [`Yield] in
_final_read_operation_for
. As mentioned in my lengthy comment, I thinkthe real issue here is that if we want to circumvent
Reader.next
, wehave to make sure we're not yielding when the reader cannot take any
more input anyway.
I thought of fixing this in a few ways, like adding explicit yielding
and continuing mechanisms to the reader at request boundaries, which is
something that has come up in the past as being a bit tricky to reason
about. I also considered just tossing this check at the top of
next_read_operation
, but it feels like the kind of thing that I'dlater ask "why is this necessary?" I want so badly for the reading and
writing behaviors to be parallel, so I did something that is meant to
feel less permanent.
This test also fails before the
refactor-request-queue
branch. I foundit curious, but then realized that
Server_connection.shutdown
is notused in either of our runtimes, so it's not too surprising that we
didn't have decent coverage of it.
Note on testing
One of the solutions I tried was to change the
peristent_connection
branch to also check closed state. But then I realized that you could
have a closed reader but still want to process more connections, so you
wouldn't want to simply shut the whole thing down. I added a missing
test that will fail if you do the wrong thing, now.